@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('NO direct script access allowed'); |
|
2 | + exit('NO direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -16,680 +16,680 @@ discard block |
||
16 | 16 | */ |
17 | 17 | //Quickfix to address https://events.codebasehq.com/projects/event-espresso/tickets/11089 ASAP |
18 | 18 | if (! function_exists('mb_strcut')) { |
19 | - /** |
|
20 | - * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr |
|
21 | - * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks) |
|
22 | - * @param $string |
|
23 | - * @param $start |
|
24 | - * @param $length |
|
25 | - * @return bool|string |
|
26 | - */ |
|
27 | - function mb_strcut($string, $start, $length = null) |
|
28 | - { |
|
29 | - return mb_substr($string, $start, $length); |
|
30 | - } |
|
19 | + /** |
|
20 | + * Very simple mimic of mb_substr (which WP ensures exists in wp-includes/compat.php). Still has all the problems of mb_substr |
|
21 | + * (namely, that we might send too many characters to PayPal; however in this case they just issue a warning but nothing breaks) |
|
22 | + * @param $string |
|
23 | + * @param $start |
|
24 | + * @param $length |
|
25 | + * @return bool|string |
|
26 | + */ |
|
27 | + function mb_strcut($string, $start, $length = null) |
|
28 | + { |
|
29 | + return mb_substr($string, $start, $length); |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | class EEG_Paypal_Express extends EE_Offsite_Gateway |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * Merchant API Username. |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - protected $_api_username; |
|
41 | - |
|
42 | - /** |
|
43 | - * Merchant API Password. |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - protected $_api_password; |
|
48 | - |
|
49 | - /** |
|
50 | - * API Signature. |
|
51 | - * |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - protected $_api_signature; |
|
55 | - |
|
56 | - /** |
|
57 | - * Request Shipping address on PP checkout page. |
|
58 | - * |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - protected $_request_shipping_addr; |
|
62 | - |
|
63 | - /** |
|
64 | - * Business/personal logo. |
|
65 | - * |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - protected $_image_url; |
|
69 | - |
|
70 | - /** |
|
71 | - * gateway URL variable |
|
72 | - * |
|
73 | - * @var string |
|
74 | - */ |
|
75 | - protected $_base_gateway_url = ''; |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * EEG_Paypal_Express constructor. |
|
81 | - */ |
|
82 | - public function __construct() |
|
83 | - { |
|
84 | - $this->_currencies_supported = array( |
|
85 | - 'USD', |
|
86 | - 'AUD', |
|
87 | - 'BRL', |
|
88 | - 'CAD', |
|
89 | - 'CZK', |
|
90 | - 'DKK', |
|
91 | - 'EUR', |
|
92 | - 'HKD', |
|
93 | - 'HUF', |
|
94 | - 'ILS', |
|
95 | - 'JPY', |
|
96 | - 'MYR', |
|
97 | - 'MXN', |
|
98 | - 'NOK', |
|
99 | - 'NZD', |
|
100 | - 'PHP', |
|
101 | - 'PLN', |
|
102 | - 'GBP', |
|
103 | - 'RUB', |
|
104 | - 'SGD', |
|
105 | - 'SEK', |
|
106 | - 'CHF', |
|
107 | - 'TWD', |
|
108 | - 'THB', |
|
109 | - 'TRY', |
|
110 | - ); |
|
111 | - parent::__construct(); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
118 | - * |
|
119 | - * @param array $settings_array |
|
120 | - */ |
|
121 | - public function set_settings($settings_array) |
|
122 | - { |
|
123 | - parent::set_settings($settings_array); |
|
124 | - // Redirect URL. |
|
125 | - $this->_base_gateway_url = $this->_debug_mode |
|
126 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
127 | - : 'https://api-3t.paypal.com/nvp'; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @param EEI_Payment $payment |
|
134 | - * @param array $billing_info |
|
135 | - * @param string $return_url |
|
136 | - * @param string $notify_url |
|
137 | - * @param string $cancel_url |
|
138 | - * @return \EE_Payment|\EEI_Payment |
|
139 | - * @throws \EE_Error |
|
140 | - */ |
|
141 | - public function set_redirection_info( |
|
142 | - $payment, |
|
143 | - $billing_info = array(), |
|
144 | - $return_url = null, |
|
145 | - $notify_url = null, |
|
146 | - $cancel_url = null |
|
147 | - ) { |
|
148 | - if (! $payment instanceof EEI_Payment) { |
|
149 | - $payment->set_gateway_response( |
|
150 | - esc_html__( |
|
151 | - 'Error. No associated payment was found.', |
|
152 | - 'event_espresso' |
|
153 | - ) |
|
154 | - ); |
|
155 | - $payment->set_status($this->_pay_model->failed_status()); |
|
156 | - return $payment; |
|
157 | - } |
|
158 | - $transaction = $payment->transaction(); |
|
159 | - if (! $transaction instanceof EEI_Transaction) { |
|
160 | - $payment->set_gateway_response( |
|
161 | - esc_html__( |
|
162 | - 'Could not process this payment because it has no associated transaction.', |
|
163 | - 'event_espresso' |
|
164 | - ) |
|
165 | - ); |
|
166 | - $payment->set_status($this->_pay_model->failed_status()); |
|
167 | - return $payment; |
|
168 | - } |
|
169 | - $gateway_formatter = $this->_get_gateway_formatter(); |
|
170 | - $order_description = mb_strcut($gateway_formatter->formatOrderDescription($payment), 0, 127); |
|
171 | - $primary_registration = $transaction->primary_registration(); |
|
172 | - $primary_attendee = $primary_registration instanceof EE_Registration |
|
173 | - ? $primary_registration->attendee() |
|
174 | - : false; |
|
175 | - $locale = explode('-', get_bloginfo('language')); |
|
176 | - // Gather request parameters. |
|
177 | - $token_request_dtls = array( |
|
178 | - 'METHOD' => 'SetExpressCheckout', |
|
179 | - 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
180 | - 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
181 | - 'PAYMENTREQUEST_0_DESC' => $order_description, |
|
182 | - 'RETURNURL' => $return_url, |
|
183 | - 'CANCELURL' => $cancel_url, |
|
184 | - 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
185 | - // Buyer does not need to create a PayPal account to check out. |
|
186 | - // This is referred to as PayPal Account Optional. |
|
187 | - 'SOLUTIONTYPE' => 'Sole', |
|
188 | - //EE will blow up if you change this |
|
189 | - 'BUTTONSOURCE' => 'EventEspresso_SP', |
|
190 | - // Locale of the pages displayed by PayPal during Express Checkout. |
|
191 | - 'LOCALECODE' => $locale[1] |
|
192 | - ); |
|
193 | - // Show itemized list. |
|
194 | - $itemized_list = $this->itemize_list($payment, $transaction); |
|
195 | - $token_request_dtls = array_merge($token_request_dtls, $itemized_list); |
|
196 | - // Automatically filling out shipping and contact information. |
|
197 | - if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
198 | - // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
199 | - $token_request_dtls['NOSHIPPING'] = '2'; |
|
200 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
|
201 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
|
202 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
|
203 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev(); |
|
204 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID(); |
|
205 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
|
206 | - $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
|
207 | - $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
|
208 | - } elseif (! $this->_request_shipping_addr) { |
|
209 | - // Do not request shipping details on the PP Checkout page. |
|
210 | - $token_request_dtls['NOSHIPPING'] = '1'; |
|
211 | - $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
|
212 | - } |
|
213 | - // Used a business/personal logo on the PayPal page. |
|
214 | - if (! empty($this->_image_url)) { |
|
215 | - $token_request_dtls['LOGOIMG'] = $this->_image_url; |
|
216 | - } |
|
217 | - $token_request_dtls = apply_filters( |
|
218 | - 'FHEE__EEG_Paypal_Express__set_redirection_info__arguments', |
|
219 | - $token_request_dtls, |
|
220 | - $this |
|
221 | - ); |
|
222 | - // Request PayPal token. |
|
223 | - $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
224 | - $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
225 | - $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) |
|
226 | - ? $token_rstatus['args'] |
|
227 | - : array(); |
|
228 | - if ($token_rstatus['status']) { |
|
229 | - // We got the Token so we may continue with the payment and redirect the client. |
|
230 | - $payment->set_details($response_args); |
|
231 | - $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
232 | - $payment->set_redirect_url( |
|
233 | - $gateway_url |
|
234 | - . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' |
|
235 | - . $response_args['TOKEN'] |
|
236 | - ); |
|
237 | - } else { |
|
238 | - if (isset($response_args['L_ERRORCODE'])) { |
|
239 | - $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']); |
|
240 | - } else { |
|
241 | - $payment->set_gateway_response( |
|
242 | - esc_html__( |
|
243 | - 'Error occurred while trying to setup the Express Checkout.', |
|
244 | - 'event_espresso' |
|
245 | - ) |
|
246 | - ); |
|
247 | - } |
|
248 | - $payment->set_details($response_args); |
|
249 | - $payment->set_status($this->_pay_model->failed_status()); |
|
250 | - } |
|
251 | - return $payment; |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * @param array $update_info { |
|
258 | - * @type string $gateway_txn_id |
|
259 | - * @type string status an EEMI_Payment status |
|
260 | - * } |
|
261 | - * @param EEI_Transaction $transaction |
|
262 | - * @return EEI_Payment |
|
263 | - */ |
|
264 | - public function handle_payment_update($update_info, $transaction) |
|
265 | - { |
|
266 | - $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
|
267 | - if ($payment instanceof EEI_Payment) { |
|
268 | - $this->log(array('Return from Authorization' => $update_info), $payment); |
|
269 | - $transaction = $payment->transaction(); |
|
270 | - if (! $transaction instanceof EEI_Transaction) { |
|
271 | - $payment->set_gateway_response( |
|
272 | - esc_html__( |
|
273 | - 'Could not process this payment because it has no associated transaction.', |
|
274 | - 'event_espresso' |
|
275 | - ) |
|
276 | - ); |
|
277 | - $payment->set_status($this->_pay_model->failed_status()); |
|
278 | - return $payment; |
|
279 | - } |
|
280 | - $primary_registrant = $transaction->primary_registration(); |
|
281 | - $payment_details = $payment->details(); |
|
282 | - // Check if we still have the token. |
|
283 | - if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
284 | - $payment->set_status($this->_pay_model->failed_status()); |
|
285 | - return $payment; |
|
286 | - } |
|
287 | - $cdetails_request_dtls = array( |
|
288 | - 'METHOD' => 'GetExpressCheckoutDetails', |
|
289 | - 'TOKEN' => $payment_details['TOKEN'], |
|
290 | - ); |
|
291 | - // Request Customer Details. |
|
292 | - $cdetails_request_response = $this->_ppExpress_request( |
|
293 | - $cdetails_request_dtls, |
|
294 | - 'Customer Details', |
|
295 | - $payment |
|
296 | - ); |
|
297 | - $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
298 | - $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) |
|
299 | - ? $cdetails_rstatus['args'] |
|
300 | - : array(); |
|
301 | - if ($cdetails_rstatus['status']) { |
|
302 | - // We got the PayerID so now we can Complete the transaction. |
|
303 | - $docheckout_request_dtls = array( |
|
304 | - 'METHOD' => 'DoExpressCheckoutPayment', |
|
305 | - 'PAYERID' => $cdata_response_args['PAYERID'], |
|
306 | - 'TOKEN' => $payment_details['TOKEN'], |
|
307 | - 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
308 | - 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
309 | - 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
310 | - //EE will blow up if you change this |
|
311 | - 'BUTTONSOURCE' => 'EventEspresso_SP', |
|
312 | - ); |
|
313 | - // Include itemized list. |
|
314 | - $itemized_list = $this->itemize_list( |
|
315 | - $payment, |
|
316 | - $transaction, |
|
317 | - $cdata_response_args |
|
318 | - ); |
|
319 | - $docheckout_request_dtls = array_merge($docheckout_request_dtls, $itemized_list); |
|
320 | - // Payment Checkout/Capture. |
|
321 | - $docheckout_request_response = $this->_ppExpress_request( |
|
322 | - $docheckout_request_dtls, |
|
323 | - 'Do Payment', |
|
324 | - $payment |
|
325 | - ); |
|
326 | - $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
327 | - $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) |
|
328 | - ? $docheckout_rstatus['args'] |
|
329 | - : array(); |
|
330 | - if ($docheckout_rstatus['status']) { |
|
331 | - // All is well, payment approved. |
|
332 | - $primary_registration_code = $primary_registrant instanceof EE_Registration ? |
|
333 | - $primary_registrant->reg_code() |
|
334 | - : ''; |
|
335 | - $payment->set_extra_accntng($primary_registration_code); |
|
336 | - $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) |
|
337 | - ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT'] |
|
338 | - : 0); |
|
339 | - $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
340 | - ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] |
|
341 | - : null); |
|
342 | - $payment->set_details($cdata_response_args); |
|
343 | - $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) |
|
344 | - ? $docheckout_response_args['PAYMENTINFO_0_ACK'] |
|
345 | - : ''); |
|
346 | - $payment->set_status($this->_pay_model->approved_status()); |
|
347 | - } else { |
|
348 | - if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
349 | - $payment->set_gateway_response( |
|
350 | - $docheckout_response_args['L_ERRORCODE'] |
|
351 | - . '; ' |
|
352 | - . $docheckout_response_args['L_SHORTMESSAGE'] |
|
353 | - ); |
|
354 | - } else { |
|
355 | - $payment->set_gateway_response( |
|
356 | - esc_html__( |
|
357 | - 'Error occurred while trying to Capture the funds.', |
|
358 | - 'event_espresso' |
|
359 | - ) |
|
360 | - ); |
|
361 | - } |
|
362 | - $payment->set_details($docheckout_response_args); |
|
363 | - $payment->set_status($this->_pay_model->declined_status()); |
|
364 | - } |
|
365 | - } else { |
|
366 | - if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
367 | - $payment->set_gateway_response( |
|
368 | - $cdata_response_args['L_ERRORCODE'] |
|
369 | - . '; ' |
|
370 | - . $cdata_response_args['L_SHORTMESSAGE'] |
|
371 | - ); |
|
372 | - } else { |
|
373 | - $payment->set_gateway_response( |
|
374 | - esc_html__( |
|
375 | - 'Error occurred while trying to get payment Details from PayPal.', |
|
376 | - 'event_espresso' |
|
377 | - ) |
|
378 | - ); |
|
379 | - } |
|
380 | - $payment->set_details($cdata_response_args); |
|
381 | - $payment->set_status($this->_pay_model->failed_status()); |
|
382 | - } |
|
383 | - } else { |
|
384 | - $payment->set_gateway_response( |
|
385 | - esc_html__( |
|
386 | - 'Error occurred while trying to process the payment.', |
|
387 | - 'event_espresso' |
|
388 | - ) |
|
389 | - ); |
|
390 | - $payment->set_status($this->_pay_model->failed_status()); |
|
391 | - } |
|
392 | - return $payment; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * Make a list of items that are in the giver transaction. |
|
399 | - * |
|
400 | - * @param EEI_Payment $payment |
|
401 | - * @param EEI_Transaction $transaction |
|
402 | - * @param array $request_response_args Data from a previous communication with PP. |
|
403 | - * @return array |
|
404 | - */ |
|
405 | - public function itemize_list(EEI_Payment $payment, EEI_Transaction $transaction, $request_response_args = array()) |
|
406 | - { |
|
407 | - $itemized_list = array(); |
|
408 | - $gateway_formatter = $this->_get_gateway_formatter(); |
|
409 | - // If we have data from a previous communication with PP (on this transaction) we may use that for our list... |
|
410 | - if ( |
|
411 | - ! empty($request_response_args) |
|
412 | - && array_key_exists('L_PAYMENTREQUEST_0_AMT0', $request_response_args) |
|
413 | - && array_key_exists('PAYMENTREQUEST_0_ITEMAMT', $request_response_args) |
|
414 | - ) { |
|
415 | - foreach ($request_response_args as $arg_key => $arg_val) { |
|
416 | - if ( |
|
417 | - strpos($arg_key, 'PAYMENTREQUEST_') !== false |
|
418 | - && strpos($arg_key, 'NOTIFYURL') === false |
|
419 | - ) { |
|
420 | - $itemized_list[$arg_key] = $arg_val; |
|
421 | - } |
|
422 | - } |
|
423 | - // If we got only a few Items then something is not right. |
|
424 | - if (count($itemized_list) > 2) { |
|
425 | - return $itemized_list; |
|
426 | - } else { |
|
427 | - if (WP_DEBUG) { |
|
428 | - throw new EE_Error( |
|
429 | - sprintf( |
|
430 | - esc_html__( |
|
431 | - // @codingStandardsIgnoreStart |
|
432 | - 'Unable to continue with the checkout because a proper purchase list could not be generated. The purchased list we could have sent was %1$s', |
|
433 | - // @codingStandardsIgnoreEnd |
|
434 | - 'event_espresso' |
|
435 | - ), |
|
436 | - wp_json_encode($itemized_list) |
|
437 | - ) |
|
438 | - ); |
|
439 | - } |
|
440 | - // Reset the list and log an error, maybe allow to try and generate a new list (below). |
|
441 | - $itemized_list = array(); |
|
442 | - $this->log( |
|
443 | - array( |
|
444 | - esc_html__( |
|
445 | - 'Could not generate a proper item list with:', |
|
446 | - 'event_espresso' |
|
447 | - ) => $request_response_args |
|
448 | - ), |
|
449 | - $payment |
|
450 | - ); |
|
451 | - } |
|
452 | - } |
|
453 | - // ...otherwise we generate a new list for this transaction. |
|
454 | - if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
455 | - $item_num = 0; |
|
456 | - $itemized_sum = 0; |
|
457 | - $total_line_items = $transaction->total_line_item(); |
|
458 | - // Go through each item in the list. |
|
459 | - foreach ($total_line_items->get_items() as $line_item) { |
|
460 | - if ($line_item instanceof EE_Line_Item) { |
|
461 | - // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
|
462 | - if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
463 | - continue; |
|
464 | - } |
|
465 | - $unit_price = $line_item->unit_price(); |
|
466 | - $line_item_quantity = $line_item->quantity(); |
|
467 | - // This is a discount. |
|
468 | - if ($line_item->is_percent()) { |
|
469 | - $unit_price = $line_item->total(); |
|
470 | - $line_item_quantity = 1; |
|
471 | - } |
|
472 | - // Item Name. |
|
473 | - $itemized_list['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut( |
|
474 | - $gateway_formatter->formatLineItemName($line_item, $payment), |
|
475 | - 0, |
|
476 | - 127 |
|
477 | - ); |
|
478 | - // Item description. |
|
479 | - $itemized_list['L_PAYMENTREQUEST_0_DESC' . $item_num] = mb_strcut( |
|
480 | - $gateway_formatter->formatLineItemDesc($line_item, $payment), |
|
481 | - 0, |
|
482 | - 127 |
|
483 | - ); |
|
484 | - // Cost of individual item. |
|
485 | - $itemized_list['L_PAYMENTREQUEST_0_AMT' . $item_num] = $gateway_formatter->formatCurrency($unit_price); |
|
486 | - // Item Number. |
|
487 | - $itemized_list['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
488 | - // Item quantity. |
|
489 | - $itemized_list['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity; |
|
490 | - // Digital item is sold. |
|
491 | - $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
492 | - $itemized_sum += $line_item->total(); |
|
493 | - ++$item_num; |
|
494 | - } |
|
495 | - } |
|
496 | - // Item's sales S/H and tax amount. |
|
497 | - $itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total(); |
|
498 | - $itemized_list['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax(); |
|
499 | - $itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
500 | - $itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
501 | - $itemized_sum_diff_from_txn_total = round( |
|
502 | - $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), |
|
503 | - 2 |
|
504 | - ); |
|
505 | - // If we were not able to recognize some item like promotion, surcharge or cancellation, |
|
506 | - // add the difference as an extra line item. |
|
507 | - if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
508 | - // Item Name. |
|
509 | - $itemized_list['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut( |
|
510 | - esc_html__( |
|
511 | - 'Other (promotion/surcharge/cancellation)', |
|
512 | - 'event_espresso' |
|
513 | - ), |
|
514 | - 0, |
|
515 | - 127 |
|
516 | - ); |
|
517 | - // Item description. |
|
518 | - $itemized_list['L_PAYMENTREQUEST_0_DESC' . $item_num] = ''; |
|
519 | - // Cost of individual item. |
|
520 | - $itemized_list['L_PAYMENTREQUEST_0_AMT' . $item_num] = $gateway_formatter->formatCurrency( |
|
521 | - $itemized_sum_diff_from_txn_total |
|
522 | - ); |
|
523 | - // Item Number. |
|
524 | - $itemized_list['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
525 | - // Item quantity. |
|
526 | - $itemized_list['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1; |
|
527 | - // Digital item is sold. |
|
528 | - $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
529 | - $item_num++; |
|
530 | - } |
|
531 | - } else { |
|
532 | - // Just one Item. |
|
533 | - // Item Name. |
|
534 | - $itemized_list['L_PAYMENTREQUEST_0_NAME0'] = mb_strcut( |
|
535 | - $gateway_formatter->formatPartialPaymentLineItemName($payment), |
|
536 | - 0, |
|
537 | - 127 |
|
538 | - ); |
|
539 | - // Item description. |
|
540 | - $itemized_list['L_PAYMENTREQUEST_0_DESC0'] = mb_strcut( |
|
541 | - $gateway_formatter->formatPartialPaymentLineItemDesc($payment), |
|
542 | - 0, |
|
543 | - 127 |
|
544 | - ); |
|
545 | - // Cost of individual item. |
|
546 | - $itemized_list['L_PAYMENTREQUEST_0_AMT0'] = $gateway_formatter->formatCurrency($payment->amount()); |
|
547 | - // Item Number. |
|
548 | - $itemized_list['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
|
549 | - // Item quantity. |
|
550 | - $itemized_list['L_PAYMENTREQUEST_0_QTY0'] = 1; |
|
551 | - // Digital item is sold. |
|
552 | - $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
|
553 | - // Item's sales S/H and tax amount. |
|
554 | - $itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $gateway_formatter->formatCurrency($payment->amount()); |
|
555 | - $itemized_list['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
|
556 | - $itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
557 | - $itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
558 | - } |
|
559 | - return $itemized_list; |
|
560 | - } |
|
561 | - |
|
562 | - |
|
563 | - |
|
564 | - /** |
|
565 | - * Make the Express checkout request. |
|
566 | - * |
|
567 | - * @param array $request_params |
|
568 | - * @param string $request_text |
|
569 | - * @param EEI_Payment $payment |
|
570 | - * @return mixed |
|
571 | - */ |
|
572 | - public function _ppExpress_request($request_params, $request_text, $payment) |
|
573 | - { |
|
574 | - $request_dtls = array( |
|
575 | - 'VERSION' => '204.0', |
|
576 | - 'USER' => urlencode($this->_api_username), |
|
577 | - 'PWD' => urlencode($this->_api_password), |
|
578 | - 'SIGNATURE' => urlencode($this->_api_signature), |
|
579 | - ); |
|
580 | - $dtls = array_merge($request_dtls, $request_params); |
|
581 | - $this->_log_clean_request($dtls, $payment, $request_text . ' Request'); |
|
582 | - // Request Customer Details. |
|
583 | - $request_response = wp_remote_post( |
|
584 | - $this->_base_gateway_url, |
|
585 | - array( |
|
586 | - 'method' => 'POST', |
|
587 | - 'timeout' => 45, |
|
588 | - 'httpversion' => '1.1', |
|
589 | - 'cookies' => array(), |
|
590 | - 'headers' => array(), |
|
591 | - 'body' => http_build_query($dtls, '', '&'), |
|
592 | - ) |
|
593 | - ); |
|
594 | - // Log the response. |
|
595 | - $this->log(array($request_text . ' Response' => $request_response), $payment); |
|
596 | - return $request_response; |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * Check the response status. |
|
603 | - * |
|
604 | - * @param mixed $request_response |
|
605 | - * @return array |
|
606 | - */ |
|
607 | - public function _ppExpress_check_response($request_response) |
|
608 | - { |
|
609 | - if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
610 | - // If we got here then there was an error in this request. |
|
611 | - return array('status' => false, 'args' => $request_response); |
|
612 | - } |
|
613 | - $response_args = array(); |
|
614 | - parse_str(urldecode($request_response['body']), $response_args); |
|
615 | - if (! isset($response_args['ACK'])) { |
|
616 | - return array('status' => false, 'args' => $request_response); |
|
617 | - } |
|
618 | - if ( |
|
619 | - ( |
|
620 | - isset($response_args['PAYERID']) |
|
621 | - || isset($response_args['TOKEN']) |
|
622 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
623 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
624 | - ) |
|
625 | - && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
626 | - ) { |
|
627 | - // Response status OK, return response parameters for further processing. |
|
628 | - return array('status' => true, 'args' => $response_args); |
|
629 | - } |
|
630 | - $errors = $this->_get_errors($response_args); |
|
631 | - return array('status' => false, 'args' => $errors); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - |
|
636 | - /** |
|
637 | - * Log a "Cleared" request. |
|
638 | - * |
|
639 | - * @param array $request |
|
640 | - * @param EEI_Payment $payment |
|
641 | - * @param string $info |
|
642 | - * @return void |
|
643 | - */ |
|
644 | - private function _log_clean_request($request, $payment, $info) |
|
645 | - { |
|
646 | - $cleaned_request_data = $request; |
|
647 | - unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
|
648 | - $this->log(array($info => $cleaned_request_data), $payment); |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - |
|
653 | - /** |
|
654 | - * Get error from the response data. |
|
655 | - * |
|
656 | - * @param array $data_array |
|
657 | - * @return array |
|
658 | - */ |
|
659 | - private function _get_errors($data_array) |
|
660 | - { |
|
661 | - $errors = array(); |
|
662 | - $n = 0; |
|
663 | - while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
664 | - $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
|
665 | - ? $data_array["L_ERRORCODE{$n}"] |
|
666 | - : ''; |
|
667 | - $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
|
668 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
669 | - : ''; |
|
670 | - $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
|
671 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
672 | - : ''; |
|
673 | - $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
|
674 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
675 | - : ''; |
|
676 | - if ($n === 0) { |
|
677 | - $errors = array( |
|
678 | - 'L_ERRORCODE' => $l_error_code, |
|
679 | - 'L_SHORTMESSAGE' => $l_short_message, |
|
680 | - 'L_LONGMESSAGE' => $l_long_message, |
|
681 | - 'L_SEVERITYCODE' => $l_severity_code, |
|
682 | - ); |
|
683 | - } else { |
|
684 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
685 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
686 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
687 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
688 | - } |
|
689 | - $n++; |
|
690 | - } |
|
691 | - return $errors; |
|
692 | - } |
|
35 | + /** |
|
36 | + * Merchant API Username. |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + protected $_api_username; |
|
41 | + |
|
42 | + /** |
|
43 | + * Merchant API Password. |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + protected $_api_password; |
|
48 | + |
|
49 | + /** |
|
50 | + * API Signature. |
|
51 | + * |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + protected $_api_signature; |
|
55 | + |
|
56 | + /** |
|
57 | + * Request Shipping address on PP checkout page. |
|
58 | + * |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + protected $_request_shipping_addr; |
|
62 | + |
|
63 | + /** |
|
64 | + * Business/personal logo. |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $_image_url; |
|
69 | + |
|
70 | + /** |
|
71 | + * gateway URL variable |
|
72 | + * |
|
73 | + * @var string |
|
74 | + */ |
|
75 | + protected $_base_gateway_url = ''; |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * EEG_Paypal_Express constructor. |
|
81 | + */ |
|
82 | + public function __construct() |
|
83 | + { |
|
84 | + $this->_currencies_supported = array( |
|
85 | + 'USD', |
|
86 | + 'AUD', |
|
87 | + 'BRL', |
|
88 | + 'CAD', |
|
89 | + 'CZK', |
|
90 | + 'DKK', |
|
91 | + 'EUR', |
|
92 | + 'HKD', |
|
93 | + 'HUF', |
|
94 | + 'ILS', |
|
95 | + 'JPY', |
|
96 | + 'MYR', |
|
97 | + 'MXN', |
|
98 | + 'NOK', |
|
99 | + 'NZD', |
|
100 | + 'PHP', |
|
101 | + 'PLN', |
|
102 | + 'GBP', |
|
103 | + 'RUB', |
|
104 | + 'SGD', |
|
105 | + 'SEK', |
|
106 | + 'CHF', |
|
107 | + 'TWD', |
|
108 | + 'THB', |
|
109 | + 'TRY', |
|
110 | + ); |
|
111 | + parent::__construct(); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
118 | + * |
|
119 | + * @param array $settings_array |
|
120 | + */ |
|
121 | + public function set_settings($settings_array) |
|
122 | + { |
|
123 | + parent::set_settings($settings_array); |
|
124 | + // Redirect URL. |
|
125 | + $this->_base_gateway_url = $this->_debug_mode |
|
126 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
127 | + : 'https://api-3t.paypal.com/nvp'; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @param EEI_Payment $payment |
|
134 | + * @param array $billing_info |
|
135 | + * @param string $return_url |
|
136 | + * @param string $notify_url |
|
137 | + * @param string $cancel_url |
|
138 | + * @return \EE_Payment|\EEI_Payment |
|
139 | + * @throws \EE_Error |
|
140 | + */ |
|
141 | + public function set_redirection_info( |
|
142 | + $payment, |
|
143 | + $billing_info = array(), |
|
144 | + $return_url = null, |
|
145 | + $notify_url = null, |
|
146 | + $cancel_url = null |
|
147 | + ) { |
|
148 | + if (! $payment instanceof EEI_Payment) { |
|
149 | + $payment->set_gateway_response( |
|
150 | + esc_html__( |
|
151 | + 'Error. No associated payment was found.', |
|
152 | + 'event_espresso' |
|
153 | + ) |
|
154 | + ); |
|
155 | + $payment->set_status($this->_pay_model->failed_status()); |
|
156 | + return $payment; |
|
157 | + } |
|
158 | + $transaction = $payment->transaction(); |
|
159 | + if (! $transaction instanceof EEI_Transaction) { |
|
160 | + $payment->set_gateway_response( |
|
161 | + esc_html__( |
|
162 | + 'Could not process this payment because it has no associated transaction.', |
|
163 | + 'event_espresso' |
|
164 | + ) |
|
165 | + ); |
|
166 | + $payment->set_status($this->_pay_model->failed_status()); |
|
167 | + return $payment; |
|
168 | + } |
|
169 | + $gateway_formatter = $this->_get_gateway_formatter(); |
|
170 | + $order_description = mb_strcut($gateway_formatter->formatOrderDescription($payment), 0, 127); |
|
171 | + $primary_registration = $transaction->primary_registration(); |
|
172 | + $primary_attendee = $primary_registration instanceof EE_Registration |
|
173 | + ? $primary_registration->attendee() |
|
174 | + : false; |
|
175 | + $locale = explode('-', get_bloginfo('language')); |
|
176 | + // Gather request parameters. |
|
177 | + $token_request_dtls = array( |
|
178 | + 'METHOD' => 'SetExpressCheckout', |
|
179 | + 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
180 | + 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
181 | + 'PAYMENTREQUEST_0_DESC' => $order_description, |
|
182 | + 'RETURNURL' => $return_url, |
|
183 | + 'CANCELURL' => $cancel_url, |
|
184 | + 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
185 | + // Buyer does not need to create a PayPal account to check out. |
|
186 | + // This is referred to as PayPal Account Optional. |
|
187 | + 'SOLUTIONTYPE' => 'Sole', |
|
188 | + //EE will blow up if you change this |
|
189 | + 'BUTTONSOURCE' => 'EventEspresso_SP', |
|
190 | + // Locale of the pages displayed by PayPal during Express Checkout. |
|
191 | + 'LOCALECODE' => $locale[1] |
|
192 | + ); |
|
193 | + // Show itemized list. |
|
194 | + $itemized_list = $this->itemize_list($payment, $transaction); |
|
195 | + $token_request_dtls = array_merge($token_request_dtls, $itemized_list); |
|
196 | + // Automatically filling out shipping and contact information. |
|
197 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
198 | + // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
199 | + $token_request_dtls['NOSHIPPING'] = '2'; |
|
200 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
|
201 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
|
202 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
|
203 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTATE'] = $primary_attendee->state_abbrev(); |
|
204 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE'] = $primary_attendee->country_ID(); |
|
205 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
|
206 | + $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
|
207 | + $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
|
208 | + } elseif (! $this->_request_shipping_addr) { |
|
209 | + // Do not request shipping details on the PP Checkout page. |
|
210 | + $token_request_dtls['NOSHIPPING'] = '1'; |
|
211 | + $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
|
212 | + } |
|
213 | + // Used a business/personal logo on the PayPal page. |
|
214 | + if (! empty($this->_image_url)) { |
|
215 | + $token_request_dtls['LOGOIMG'] = $this->_image_url; |
|
216 | + } |
|
217 | + $token_request_dtls = apply_filters( |
|
218 | + 'FHEE__EEG_Paypal_Express__set_redirection_info__arguments', |
|
219 | + $token_request_dtls, |
|
220 | + $this |
|
221 | + ); |
|
222 | + // Request PayPal token. |
|
223 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
224 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
225 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) |
|
226 | + ? $token_rstatus['args'] |
|
227 | + : array(); |
|
228 | + if ($token_rstatus['status']) { |
|
229 | + // We got the Token so we may continue with the payment and redirect the client. |
|
230 | + $payment->set_details($response_args); |
|
231 | + $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
232 | + $payment->set_redirect_url( |
|
233 | + $gateway_url |
|
234 | + . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' |
|
235 | + . $response_args['TOKEN'] |
|
236 | + ); |
|
237 | + } else { |
|
238 | + if (isset($response_args['L_ERRORCODE'])) { |
|
239 | + $payment->set_gateway_response($response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE']); |
|
240 | + } else { |
|
241 | + $payment->set_gateway_response( |
|
242 | + esc_html__( |
|
243 | + 'Error occurred while trying to setup the Express Checkout.', |
|
244 | + 'event_espresso' |
|
245 | + ) |
|
246 | + ); |
|
247 | + } |
|
248 | + $payment->set_details($response_args); |
|
249 | + $payment->set_status($this->_pay_model->failed_status()); |
|
250 | + } |
|
251 | + return $payment; |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * @param array $update_info { |
|
258 | + * @type string $gateway_txn_id |
|
259 | + * @type string status an EEMI_Payment status |
|
260 | + * } |
|
261 | + * @param EEI_Transaction $transaction |
|
262 | + * @return EEI_Payment |
|
263 | + */ |
|
264 | + public function handle_payment_update($update_info, $transaction) |
|
265 | + { |
|
266 | + $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
|
267 | + if ($payment instanceof EEI_Payment) { |
|
268 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
269 | + $transaction = $payment->transaction(); |
|
270 | + if (! $transaction instanceof EEI_Transaction) { |
|
271 | + $payment->set_gateway_response( |
|
272 | + esc_html__( |
|
273 | + 'Could not process this payment because it has no associated transaction.', |
|
274 | + 'event_espresso' |
|
275 | + ) |
|
276 | + ); |
|
277 | + $payment->set_status($this->_pay_model->failed_status()); |
|
278 | + return $payment; |
|
279 | + } |
|
280 | + $primary_registrant = $transaction->primary_registration(); |
|
281 | + $payment_details = $payment->details(); |
|
282 | + // Check if we still have the token. |
|
283 | + if (! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
284 | + $payment->set_status($this->_pay_model->failed_status()); |
|
285 | + return $payment; |
|
286 | + } |
|
287 | + $cdetails_request_dtls = array( |
|
288 | + 'METHOD' => 'GetExpressCheckoutDetails', |
|
289 | + 'TOKEN' => $payment_details['TOKEN'], |
|
290 | + ); |
|
291 | + // Request Customer Details. |
|
292 | + $cdetails_request_response = $this->_ppExpress_request( |
|
293 | + $cdetails_request_dtls, |
|
294 | + 'Customer Details', |
|
295 | + $payment |
|
296 | + ); |
|
297 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
298 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) |
|
299 | + ? $cdetails_rstatus['args'] |
|
300 | + : array(); |
|
301 | + if ($cdetails_rstatus['status']) { |
|
302 | + // We got the PayerID so now we can Complete the transaction. |
|
303 | + $docheckout_request_dtls = array( |
|
304 | + 'METHOD' => 'DoExpressCheckoutPayment', |
|
305 | + 'PAYERID' => $cdata_response_args['PAYERID'], |
|
306 | + 'TOKEN' => $payment_details['TOKEN'], |
|
307 | + 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
|
308 | + 'PAYMENTREQUEST_0_AMT' => $payment->amount(), |
|
309 | + 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code(), |
|
310 | + //EE will blow up if you change this |
|
311 | + 'BUTTONSOURCE' => 'EventEspresso_SP', |
|
312 | + ); |
|
313 | + // Include itemized list. |
|
314 | + $itemized_list = $this->itemize_list( |
|
315 | + $payment, |
|
316 | + $transaction, |
|
317 | + $cdata_response_args |
|
318 | + ); |
|
319 | + $docheckout_request_dtls = array_merge($docheckout_request_dtls, $itemized_list); |
|
320 | + // Payment Checkout/Capture. |
|
321 | + $docheckout_request_response = $this->_ppExpress_request( |
|
322 | + $docheckout_request_dtls, |
|
323 | + 'Do Payment', |
|
324 | + $payment |
|
325 | + ); |
|
326 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
327 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) |
|
328 | + ? $docheckout_rstatus['args'] |
|
329 | + : array(); |
|
330 | + if ($docheckout_rstatus['status']) { |
|
331 | + // All is well, payment approved. |
|
332 | + $primary_registration_code = $primary_registrant instanceof EE_Registration ? |
|
333 | + $primary_registrant->reg_code() |
|
334 | + : ''; |
|
335 | + $payment->set_extra_accntng($primary_registration_code); |
|
336 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) |
|
337 | + ? (float)$docheckout_response_args['PAYMENTINFO_0_AMT'] |
|
338 | + : 0); |
|
339 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
340 | + ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] |
|
341 | + : null); |
|
342 | + $payment->set_details($cdata_response_args); |
|
343 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) |
|
344 | + ? $docheckout_response_args['PAYMENTINFO_0_ACK'] |
|
345 | + : ''); |
|
346 | + $payment->set_status($this->_pay_model->approved_status()); |
|
347 | + } else { |
|
348 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
349 | + $payment->set_gateway_response( |
|
350 | + $docheckout_response_args['L_ERRORCODE'] |
|
351 | + . '; ' |
|
352 | + . $docheckout_response_args['L_SHORTMESSAGE'] |
|
353 | + ); |
|
354 | + } else { |
|
355 | + $payment->set_gateway_response( |
|
356 | + esc_html__( |
|
357 | + 'Error occurred while trying to Capture the funds.', |
|
358 | + 'event_espresso' |
|
359 | + ) |
|
360 | + ); |
|
361 | + } |
|
362 | + $payment->set_details($docheckout_response_args); |
|
363 | + $payment->set_status($this->_pay_model->declined_status()); |
|
364 | + } |
|
365 | + } else { |
|
366 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
367 | + $payment->set_gateway_response( |
|
368 | + $cdata_response_args['L_ERRORCODE'] |
|
369 | + . '; ' |
|
370 | + . $cdata_response_args['L_SHORTMESSAGE'] |
|
371 | + ); |
|
372 | + } else { |
|
373 | + $payment->set_gateway_response( |
|
374 | + esc_html__( |
|
375 | + 'Error occurred while trying to get payment Details from PayPal.', |
|
376 | + 'event_espresso' |
|
377 | + ) |
|
378 | + ); |
|
379 | + } |
|
380 | + $payment->set_details($cdata_response_args); |
|
381 | + $payment->set_status($this->_pay_model->failed_status()); |
|
382 | + } |
|
383 | + } else { |
|
384 | + $payment->set_gateway_response( |
|
385 | + esc_html__( |
|
386 | + 'Error occurred while trying to process the payment.', |
|
387 | + 'event_espresso' |
|
388 | + ) |
|
389 | + ); |
|
390 | + $payment->set_status($this->_pay_model->failed_status()); |
|
391 | + } |
|
392 | + return $payment; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * Make a list of items that are in the giver transaction. |
|
399 | + * |
|
400 | + * @param EEI_Payment $payment |
|
401 | + * @param EEI_Transaction $transaction |
|
402 | + * @param array $request_response_args Data from a previous communication with PP. |
|
403 | + * @return array |
|
404 | + */ |
|
405 | + public function itemize_list(EEI_Payment $payment, EEI_Transaction $transaction, $request_response_args = array()) |
|
406 | + { |
|
407 | + $itemized_list = array(); |
|
408 | + $gateway_formatter = $this->_get_gateway_formatter(); |
|
409 | + // If we have data from a previous communication with PP (on this transaction) we may use that for our list... |
|
410 | + if ( |
|
411 | + ! empty($request_response_args) |
|
412 | + && array_key_exists('L_PAYMENTREQUEST_0_AMT0', $request_response_args) |
|
413 | + && array_key_exists('PAYMENTREQUEST_0_ITEMAMT', $request_response_args) |
|
414 | + ) { |
|
415 | + foreach ($request_response_args as $arg_key => $arg_val) { |
|
416 | + if ( |
|
417 | + strpos($arg_key, 'PAYMENTREQUEST_') !== false |
|
418 | + && strpos($arg_key, 'NOTIFYURL') === false |
|
419 | + ) { |
|
420 | + $itemized_list[$arg_key] = $arg_val; |
|
421 | + } |
|
422 | + } |
|
423 | + // If we got only a few Items then something is not right. |
|
424 | + if (count($itemized_list) > 2) { |
|
425 | + return $itemized_list; |
|
426 | + } else { |
|
427 | + if (WP_DEBUG) { |
|
428 | + throw new EE_Error( |
|
429 | + sprintf( |
|
430 | + esc_html__( |
|
431 | + // @codingStandardsIgnoreStart |
|
432 | + 'Unable to continue with the checkout because a proper purchase list could not be generated. The purchased list we could have sent was %1$s', |
|
433 | + // @codingStandardsIgnoreEnd |
|
434 | + 'event_espresso' |
|
435 | + ), |
|
436 | + wp_json_encode($itemized_list) |
|
437 | + ) |
|
438 | + ); |
|
439 | + } |
|
440 | + // Reset the list and log an error, maybe allow to try and generate a new list (below). |
|
441 | + $itemized_list = array(); |
|
442 | + $this->log( |
|
443 | + array( |
|
444 | + esc_html__( |
|
445 | + 'Could not generate a proper item list with:', |
|
446 | + 'event_espresso' |
|
447 | + ) => $request_response_args |
|
448 | + ), |
|
449 | + $payment |
|
450 | + ); |
|
451 | + } |
|
452 | + } |
|
453 | + // ...otherwise we generate a new list for this transaction. |
|
454 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
455 | + $item_num = 0; |
|
456 | + $itemized_sum = 0; |
|
457 | + $total_line_items = $transaction->total_line_item(); |
|
458 | + // Go through each item in the list. |
|
459 | + foreach ($total_line_items->get_items() as $line_item) { |
|
460 | + if ($line_item instanceof EE_Line_Item) { |
|
461 | + // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
|
462 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
463 | + continue; |
|
464 | + } |
|
465 | + $unit_price = $line_item->unit_price(); |
|
466 | + $line_item_quantity = $line_item->quantity(); |
|
467 | + // This is a discount. |
|
468 | + if ($line_item->is_percent()) { |
|
469 | + $unit_price = $line_item->total(); |
|
470 | + $line_item_quantity = 1; |
|
471 | + } |
|
472 | + // Item Name. |
|
473 | + $itemized_list['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut( |
|
474 | + $gateway_formatter->formatLineItemName($line_item, $payment), |
|
475 | + 0, |
|
476 | + 127 |
|
477 | + ); |
|
478 | + // Item description. |
|
479 | + $itemized_list['L_PAYMENTREQUEST_0_DESC' . $item_num] = mb_strcut( |
|
480 | + $gateway_formatter->formatLineItemDesc($line_item, $payment), |
|
481 | + 0, |
|
482 | + 127 |
|
483 | + ); |
|
484 | + // Cost of individual item. |
|
485 | + $itemized_list['L_PAYMENTREQUEST_0_AMT' . $item_num] = $gateway_formatter->formatCurrency($unit_price); |
|
486 | + // Item Number. |
|
487 | + $itemized_list['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
488 | + // Item quantity. |
|
489 | + $itemized_list['L_PAYMENTREQUEST_0_QTY' . $item_num] = $line_item_quantity; |
|
490 | + // Digital item is sold. |
|
491 | + $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
492 | + $itemized_sum += $line_item->total(); |
|
493 | + ++$item_num; |
|
494 | + } |
|
495 | + } |
|
496 | + // Item's sales S/H and tax amount. |
|
497 | + $itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $total_line_items->get_items_total(); |
|
498 | + $itemized_list['PAYMENTREQUEST_0_TAXAMT'] = $total_line_items->get_total_tax(); |
|
499 | + $itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
500 | + $itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
501 | + $itemized_sum_diff_from_txn_total = round( |
|
502 | + $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), |
|
503 | + 2 |
|
504 | + ); |
|
505 | + // If we were not able to recognize some item like promotion, surcharge or cancellation, |
|
506 | + // add the difference as an extra line item. |
|
507 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
508 | + // Item Name. |
|
509 | + $itemized_list['L_PAYMENTREQUEST_0_NAME' . $item_num] = mb_strcut( |
|
510 | + esc_html__( |
|
511 | + 'Other (promotion/surcharge/cancellation)', |
|
512 | + 'event_espresso' |
|
513 | + ), |
|
514 | + 0, |
|
515 | + 127 |
|
516 | + ); |
|
517 | + // Item description. |
|
518 | + $itemized_list['L_PAYMENTREQUEST_0_DESC' . $item_num] = ''; |
|
519 | + // Cost of individual item. |
|
520 | + $itemized_list['L_PAYMENTREQUEST_0_AMT' . $item_num] = $gateway_formatter->formatCurrency( |
|
521 | + $itemized_sum_diff_from_txn_total |
|
522 | + ); |
|
523 | + // Item Number. |
|
524 | + $itemized_list['L_PAYMENTREQUEST_0_NUMBER' . $item_num] = $item_num + 1; |
|
525 | + // Item quantity. |
|
526 | + $itemized_list['L_PAYMENTREQUEST_0_QTY' . $item_num] = 1; |
|
527 | + // Digital item is sold. |
|
528 | + $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY' . $item_num] = 'Physical'; |
|
529 | + $item_num++; |
|
530 | + } |
|
531 | + } else { |
|
532 | + // Just one Item. |
|
533 | + // Item Name. |
|
534 | + $itemized_list['L_PAYMENTREQUEST_0_NAME0'] = mb_strcut( |
|
535 | + $gateway_formatter->formatPartialPaymentLineItemName($payment), |
|
536 | + 0, |
|
537 | + 127 |
|
538 | + ); |
|
539 | + // Item description. |
|
540 | + $itemized_list['L_PAYMENTREQUEST_0_DESC0'] = mb_strcut( |
|
541 | + $gateway_formatter->formatPartialPaymentLineItemDesc($payment), |
|
542 | + 0, |
|
543 | + 127 |
|
544 | + ); |
|
545 | + // Cost of individual item. |
|
546 | + $itemized_list['L_PAYMENTREQUEST_0_AMT0'] = $gateway_formatter->formatCurrency($payment->amount()); |
|
547 | + // Item Number. |
|
548 | + $itemized_list['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
|
549 | + // Item quantity. |
|
550 | + $itemized_list['L_PAYMENTREQUEST_0_QTY0'] = 1; |
|
551 | + // Digital item is sold. |
|
552 | + $itemized_list['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
|
553 | + // Item's sales S/H and tax amount. |
|
554 | + $itemized_list['PAYMENTREQUEST_0_ITEMAMT'] = $gateway_formatter->formatCurrency($payment->amount()); |
|
555 | + $itemized_list['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
|
556 | + $itemized_list['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
|
557 | + $itemized_list['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
|
558 | + } |
|
559 | + return $itemized_list; |
|
560 | + } |
|
561 | + |
|
562 | + |
|
563 | + |
|
564 | + /** |
|
565 | + * Make the Express checkout request. |
|
566 | + * |
|
567 | + * @param array $request_params |
|
568 | + * @param string $request_text |
|
569 | + * @param EEI_Payment $payment |
|
570 | + * @return mixed |
|
571 | + */ |
|
572 | + public function _ppExpress_request($request_params, $request_text, $payment) |
|
573 | + { |
|
574 | + $request_dtls = array( |
|
575 | + 'VERSION' => '204.0', |
|
576 | + 'USER' => urlencode($this->_api_username), |
|
577 | + 'PWD' => urlencode($this->_api_password), |
|
578 | + 'SIGNATURE' => urlencode($this->_api_signature), |
|
579 | + ); |
|
580 | + $dtls = array_merge($request_dtls, $request_params); |
|
581 | + $this->_log_clean_request($dtls, $payment, $request_text . ' Request'); |
|
582 | + // Request Customer Details. |
|
583 | + $request_response = wp_remote_post( |
|
584 | + $this->_base_gateway_url, |
|
585 | + array( |
|
586 | + 'method' => 'POST', |
|
587 | + 'timeout' => 45, |
|
588 | + 'httpversion' => '1.1', |
|
589 | + 'cookies' => array(), |
|
590 | + 'headers' => array(), |
|
591 | + 'body' => http_build_query($dtls, '', '&'), |
|
592 | + ) |
|
593 | + ); |
|
594 | + // Log the response. |
|
595 | + $this->log(array($request_text . ' Response' => $request_response), $payment); |
|
596 | + return $request_response; |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * Check the response status. |
|
603 | + * |
|
604 | + * @param mixed $request_response |
|
605 | + * @return array |
|
606 | + */ |
|
607 | + public function _ppExpress_check_response($request_response) |
|
608 | + { |
|
609 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
610 | + // If we got here then there was an error in this request. |
|
611 | + return array('status' => false, 'args' => $request_response); |
|
612 | + } |
|
613 | + $response_args = array(); |
|
614 | + parse_str(urldecode($request_response['body']), $response_args); |
|
615 | + if (! isset($response_args['ACK'])) { |
|
616 | + return array('status' => false, 'args' => $request_response); |
|
617 | + } |
|
618 | + if ( |
|
619 | + ( |
|
620 | + isset($response_args['PAYERID']) |
|
621 | + || isset($response_args['TOKEN']) |
|
622 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
623 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
624 | + ) |
|
625 | + && in_array($response_args['ACK'], array('Success', 'SuccessWithWarning'), true) |
|
626 | + ) { |
|
627 | + // Response status OK, return response parameters for further processing. |
|
628 | + return array('status' => true, 'args' => $response_args); |
|
629 | + } |
|
630 | + $errors = $this->_get_errors($response_args); |
|
631 | + return array('status' => false, 'args' => $errors); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + |
|
636 | + /** |
|
637 | + * Log a "Cleared" request. |
|
638 | + * |
|
639 | + * @param array $request |
|
640 | + * @param EEI_Payment $payment |
|
641 | + * @param string $info |
|
642 | + * @return void |
|
643 | + */ |
|
644 | + private function _log_clean_request($request, $payment, $info) |
|
645 | + { |
|
646 | + $cleaned_request_data = $request; |
|
647 | + unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
|
648 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + |
|
653 | + /** |
|
654 | + * Get error from the response data. |
|
655 | + * |
|
656 | + * @param array $data_array |
|
657 | + * @return array |
|
658 | + */ |
|
659 | + private function _get_errors($data_array) |
|
660 | + { |
|
661 | + $errors = array(); |
|
662 | + $n = 0; |
|
663 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
664 | + $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
|
665 | + ? $data_array["L_ERRORCODE{$n}"] |
|
666 | + : ''; |
|
667 | + $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
|
668 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
669 | + : ''; |
|
670 | + $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
|
671 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
672 | + : ''; |
|
673 | + $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
|
674 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
675 | + : ''; |
|
676 | + if ($n === 0) { |
|
677 | + $errors = array( |
|
678 | + 'L_ERRORCODE' => $l_error_code, |
|
679 | + 'L_SHORTMESSAGE' => $l_short_message, |
|
680 | + 'L_LONGMESSAGE' => $l_long_message, |
|
681 | + 'L_SEVERITYCODE' => $l_severity_code, |
|
682 | + ); |
|
683 | + } else { |
|
684 | + $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
685 | + $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
686 | + $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
687 | + $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
688 | + } |
|
689 | + $n++; |
|
690 | + } |
|
691 | + return $errors; |
|
692 | + } |
|
693 | 693 | |
694 | 694 | } |
695 | 695 | // End of file EEG_Paypal_Express.gateway.php |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function instance() { |
34 | 34 | // check if class object is instantiated |
35 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
35 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
36 | 36 | self::$_instance = new self(); |
37 | 37 | } |
38 | 38 | return self::$_instance; |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private function __construct() { |
50 | 50 | //let's just make sure this is instantiated in the right place. |
51 | - if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) { |
|
52 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' ); |
|
51 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
52 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
@@ -61,25 +61,25 @@ discard block |
||
61 | 61 | * @return void |
62 | 62 | */ |
63 | 63 | public function register_and_enqueue() { |
64 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
65 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
66 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
64 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js'; |
|
65 | + $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map'; |
|
66 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css'; |
|
67 | 67 | |
68 | - wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE ); |
|
69 | - wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', TRUE ); |
|
70 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
68 | + wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE); |
|
69 | + wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', TRUE); |
|
70 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE); |
|
71 | 71 | |
72 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2' ); |
|
72 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
73 | 73 | |
74 | 74 | //k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
75 | - if ( !empty( $this->_qtips ) ) { |
|
75 | + if ( ! empty($this->_qtips)) { |
|
76 | 76 | wp_enqueue_script('ee-qtip-helper'); |
77 | 77 | wp_enqueue_style('qtip-css'); |
78 | 78 | $qtips = array(); |
79 | - foreach ( $this->_qtips as $qtip ) { |
|
79 | + foreach ($this->_qtips as $qtip) { |
|
80 | 80 | $qts = $qtip->get_tips(); |
81 | - foreach ( $qts as $qt ) { |
|
82 | - if ( ! $qt instanceof EE_Qtip ) |
|
81 | + foreach ($qts as $qt) { |
|
82 | + if ( ! $qt instanceof EE_Qtip) |
|
83 | 83 | continue; |
84 | 84 | $qtips[] = array( |
85 | 85 | 'content_id' => $qt->content_id, |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | ); |
89 | 89 | } |
90 | 90 | } |
91 | - if ( !empty($qtips) ) |
|
92 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) ); |
|
91 | + if ( ! empty($qtips)) |
|
92 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
93 | 93 | |
94 | 94 | } else { |
95 | 95 | //qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - public function register( $configname, $paths = array() ) { |
|
114 | + public function register($configname, $paths = array()) { |
|
115 | 115 | |
116 | 116 | //let's just make sure this is instantiated in the right place. |
117 | - if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) { |
|
118 | - EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' ); |
|
117 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
118 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $configname = (array) $configname; //typecast to array |
122 | - foreach ( $configname as $config ) { |
|
123 | - $this->_register( $config, $paths ); |
|
122 | + foreach ($configname as $config) { |
|
123 | + $this->_register($config, $paths); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | //hook into appropriate footer |
127 | 127 | $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
128 | - add_action($footer_action, array($this, 'setup_qtip'), 10 ); |
|
128 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
129 | 129 | |
130 | 130 | //make sure we "turn on" qtip js. |
131 | - add_filter('FHEE_load_qtip', '__return_true' ); |
|
131 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | * @throws EE_Error |
143 | 143 | * @return void |
144 | 144 | */ |
145 | - private function _register( $config, $paths ) { |
|
145 | + private function _register($config, $paths) { |
|
146 | 146 | //before doing anything we have to make sure that EE_Qtip_Config parent is required. |
147 | - EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE ); |
|
147 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE); |
|
148 | 148 | |
149 | - if ( !empty( $paths ) ) { |
|
149 | + if ( ! empty($paths)) { |
|
150 | 150 | $paths = (array) $paths; |
151 | - foreach ( $paths as $path ) { |
|
152 | - $path = $path . $config . '.lib.php'; |
|
153 | - if ( !is_readable($path ) ) { |
|
151 | + foreach ($paths as $path) { |
|
152 | + $path = $path.$config.'.lib.php'; |
|
153 | + if ( ! is_readable($path)) { |
|
154 | 154 | continue; |
155 | 155 | } else { |
156 | 156 | require_once $path; |
@@ -159,26 +159,26 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | //does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
162 | - if ( !class_exists($config) ) { |
|
163 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
164 | - if ( !is_readable($path ) ) { |
|
165 | - throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) ); |
|
162 | + if ( ! class_exists($config)) { |
|
163 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
164 | + if ( ! is_readable($path)) { |
|
165 | + throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
166 | 166 | } else { |
167 | 167 | require_once $path; |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | 171 | //now we attempt a class_exists one more time. |
172 | - if ( !class_exists( $config ) ) |
|
173 | - throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) ); |
|
172 | + if ( ! class_exists($config)) |
|
173 | + throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
174 | 174 | |
175 | 175 | //made it HERE? FINALLY, let's get things setup. |
176 | 176 | $a = new ReflectionClass($config); |
177 | 177 | $qtip = $a->newInstance(); |
178 | 178 | |
179 | 179 | //verify that $qtip is a valid object |
180 | - if ( ! $qtip instanceof EE_Qtip_Config ) |
|
181 | - throw new EE_Error( sprintf( esc_html__( 'The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>' ) ); |
|
180 | + if ( ! $qtip instanceof EE_Qtip_Config) |
|
181 | + throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
|
182 | 182 | |
183 | 183 | $this->_qtips[] = $a->newInstance(); |
184 | 184 | |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * @return void |
195 | 195 | */ |
196 | 196 | public function setup_qtip() { |
197 | - if ( empty( $this->_qtips ) ) |
|
197 | + if (empty($this->_qtips)) |
|
198 | 198 | return; //no qtips! |
199 | 199 | |
200 | 200 | $content = array(); |
201 | 201 | |
202 | - foreach ( $this->_qtips as $qtip ) { |
|
202 | + foreach ($this->_qtips as $qtip) { |
|
203 | 203 | $content[] = $this->_generate_content_container($qtip); |
204 | 204 | } |
205 | 205 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | private function _generate_content_container($qtip) { |
217 | 217 | $qts = $qtip->get_tips(); |
218 | 218 | $content = array(); |
219 | - foreach ( $qts as $qt ) { |
|
220 | - if ( ! $qt instanceof EE_Qtip ) |
|
219 | + foreach ($qts as $qt) { |
|
220 | + if ( ! $qt instanceof EE_Qtip) |
|
221 | 221 | continue; |
222 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>'; |
|
222 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>'; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | return implode('<br />', $content); |
@@ -19,126 +19,126 @@ |
||
19 | 19 | abstract class DomainBase implements DomainInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Equivalent to `__FILE__` for main plugin file. |
|
24 | - * |
|
25 | - * @var FilePath |
|
26 | - */ |
|
27 | - private $plugin_file; |
|
22 | + /** |
|
23 | + * Equivalent to `__FILE__` for main plugin file. |
|
24 | + * |
|
25 | + * @var FilePath |
|
26 | + */ |
|
27 | + private $plugin_file; |
|
28 | 28 | |
29 | - /** |
|
30 | - * String indicating version for plugin |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - private $version; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string $plugin_basename |
|
38 | - */ |
|
39 | - private $plugin_basename; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string $plugin_path |
|
43 | - */ |
|
44 | - private $plugin_path; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $plugin_url |
|
48 | - */ |
|
49 | - private $plugin_url; |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Initializes internal properties. |
|
55 | - * |
|
56 | - * @param FilePath $plugin_file |
|
57 | - * @param Version $version |
|
58 | - */ |
|
59 | - public function __construct(FilePath $plugin_file, Version $version) |
|
60 | - { |
|
61 | - $this->plugin_file = $plugin_file; |
|
62 | - $this->version = $version; |
|
63 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
64 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
65 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function pluginFile() |
|
73 | - { |
|
74 | - return (string) $this->plugin_file; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function pluginBasename() |
|
83 | - { |
|
84 | - return $this->plugin_basename; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function pluginPath() |
|
93 | - { |
|
94 | - return $this->plugin_path; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function pluginUrl() |
|
103 | - { |
|
104 | - return $this->plugin_url; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function version() |
|
113 | - { |
|
114 | - return (string) $this->version; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @return Version |
|
121 | - */ |
|
122 | - public function versionValueObject() |
|
123 | - { |
|
124 | - return $this->version; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function distributionAssetsPath() |
|
132 | - { |
|
133 | - return $this->pluginPath() . 'assets/dist/'; |
|
134 | - } |
|
29 | + /** |
|
30 | + * String indicating version for plugin |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + private $version; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string $plugin_basename |
|
38 | + */ |
|
39 | + private $plugin_basename; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string $plugin_path |
|
43 | + */ |
|
44 | + private $plugin_path; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $plugin_url |
|
48 | + */ |
|
49 | + private $plugin_url; |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Initializes internal properties. |
|
55 | + * |
|
56 | + * @param FilePath $plugin_file |
|
57 | + * @param Version $version |
|
58 | + */ |
|
59 | + public function __construct(FilePath $plugin_file, Version $version) |
|
60 | + { |
|
61 | + $this->plugin_file = $plugin_file; |
|
62 | + $this->version = $version; |
|
63 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
64 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
65 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function pluginFile() |
|
73 | + { |
|
74 | + return (string) $this->plugin_file; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function pluginBasename() |
|
83 | + { |
|
84 | + return $this->plugin_basename; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function pluginPath() |
|
93 | + { |
|
94 | + return $this->plugin_path; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function pluginUrl() |
|
103 | + { |
|
104 | + return $this->plugin_url; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function version() |
|
113 | + { |
|
114 | + return (string) $this->version; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @return Version |
|
121 | + */ |
|
122 | + public function versionValueObject() |
|
123 | + { |
|
124 | + return $this->version; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function distributionAssetsPath() |
|
132 | + { |
|
133 | + return $this->pluginPath() . 'assets/dist/'; |
|
134 | + } |
|
135 | 135 | |
136 | - |
|
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function distributionAssetsUrl() |
|
141 | - { |
|
142 | - return $this->pluginUrl() . 'assets/dist/'; |
|
143 | - } |
|
136 | + |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function distributionAssetsUrl() |
|
141 | + { |
|
142 | + return $this->pluginUrl() . 'assets/dist/'; |
|
143 | + } |
|
144 | 144 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function distributionAssetsPath() |
132 | 132 | { |
133 | - return $this->pluginPath() . 'assets/dist/'; |
|
133 | + return $this->pluginPath().'assets/dist/'; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -139,6 +139,6 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function distributionAssetsUrl() |
141 | 141 | { |
142 | - return $this->pluginUrl() . 'assets/dist/'; |
|
142 | + return $this->pluginUrl().'assets/dist/'; |
|
143 | 143 | } |
144 | 144 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\services\request\RequestInterface; |
8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
9 | 9 | |
10 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | 11 | exit('No direct script access allowed'); |
12 | 12 | } |
13 | 13 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public static function instance() { |
131 | 131 | // check if class object is instantiated, and instantiated properly |
132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
132 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | 133 | self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
134 | 134 | } |
135 | 135 | return self::$_instance; |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | ) { |
212 | 212 | $class = trim($class, '\\'); |
213 | 213 | $registered = false; |
214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
214 | + if (empty(self::$_instance->_dependency_map[$class])) { |
|
215 | + self::$_instance->_dependency_map[$class] = array(); |
|
216 | 216 | } |
217 | 217 | // we need to make sure that any aliases used when registering a dependency |
218 | 218 | // get resolved to the correct class name |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $alias = self::$_instance->get_alias($dependency); |
221 | 221 | if ( |
222 | 222 | $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
223 | + || ! isset(self::$_instance->_dependency_map[$class][$alias]) |
|
224 | 224 | ) { |
225 | 225 | unset($dependencies[$dependency]); |
226 | 226 | $dependencies[$alias] = $load_source; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
234 | 234 | // Union is way faster than array_merge() but should be used with caution... |
235 | 235 | // especially with numerically indexed arrays |
236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
236 | + $dependencies += self::$_instance->_dependency_map[$class]; |
|
237 | 237 | // now we need to ensure that the resulting dependencies |
238 | 238 | // array only has the entries that are required for the class |
239 | 239 | // so first count how many dependencies were originally registered for the class |
240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
240 | + $dependency_count = count(self::$_instance->_dependency_map[$class]); |
|
241 | 241 | // if that count is non-zero (meaning dependencies were already registered) |
242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
242 | + self::$_instance->_dependency_map[$class] = $dependency_count |
|
243 | 243 | // then truncate the final array to match that count |
244 | 244 | ? array_slice($dependencies, 0, $dependency_count) |
245 | 245 | // otherwise just take the incoming array because nothing previously existed |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public static function register_class_loader($class_name, $loader = 'load_core') |
259 | 259 | { |
260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
260 | + if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | 261 | throw new DomainException( |
262 | 262 | esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
263 | 263 | ); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | ); |
282 | 282 | } |
283 | 283 | $class_name = self::$_instance->get_alias($class_name); |
284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
284 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | 285 | self::$_instance->_class_loaders[$class_name] = $loader; |
286 | 286 | return true; |
287 | 287 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | public function class_loader($class_name) |
367 | 367 | { |
368 | 368 | // all legacy models use load_model() |
369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
369 | + if (strpos($class_name, 'EEM_') === 0) { |
|
370 | 370 | return 'load_model'; |
371 | 371 | } |
372 | 372 | $class_name = $this->get_alias($class_name); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | public function add_alias($class_name, $alias, $for_class = '') |
396 | 396 | { |
397 | 397 | if ($for_class !== '') { |
398 | - if (! isset($this->_aliases[$for_class])) { |
|
398 | + if ( ! isset($this->_aliases[$for_class])) { |
|
399 | 399 | $this->_aliases[$for_class] = array(); |
400 | 400 | } |
401 | 401 | $this->_aliases[$for_class][$class_name] = $alias; |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | */ |
442 | 442 | public function get_alias($class_name = '', $for_class = '') |
443 | 443 | { |
444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
444 | + if ( ! $this->has_alias($class_name, $for_class)) { |
|
445 | 445 | return $class_name; |
446 | 446 | } |
447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
447 | + if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) { |
|
448 | 448 | return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
449 | 449 | } |
450 | 450 | return $this->get_alias($this->_aliases[$class_name]); |
@@ -714,13 +714,13 @@ discard block |
||
714 | 714 | 'EE_Front_Controller' => 'load_core', |
715 | 715 | 'EE_Module_Request_Router' => 'load_core', |
716 | 716 | 'EE_Registry' => 'load_core', |
717 | - 'EE_Request' => function () use (&$legacy_request) { |
|
717 | + 'EE_Request' => function() use (&$legacy_request) { |
|
718 | 718 | return $legacy_request; |
719 | 719 | }, |
720 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
720 | + 'EventEspresso\core\services\request\Request' => function() use (&$request) { |
|
721 | 721 | return $request; |
722 | 722 | }, |
723 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
723 | + 'EventEspresso\core\services\request\Response' => function() use (&$response) { |
|
724 | 724 | return $response; |
725 | 725 | }, |
726 | 726 | 'EE_Request_Handler' => 'load_core', |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
743 | 743 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
744 | 744 | 'EE_Payment_Method_Manager' => 'load_lib', |
745 | - 'EE_Messages_Generator' => function () { |
|
745 | + 'EE_Messages_Generator' => function() { |
|
746 | 746 | return EE_Registry::instance()->load_lib( |
747 | 747 | 'Messages_Generator', |
748 | 748 | array(), |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | false |
751 | 751 | ); |
752 | 752 | }, |
753 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
753 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
754 | 754 | return EE_Registry::instance()->load_lib( |
755 | 755 | 'Messages_Template_Defaults', |
756 | 756 | $arguments, |
@@ -763,22 +763,22 @@ discard block |
||
763 | 763 | // 'EEM_Message_Template_Group' => 'load_model', |
764 | 764 | // 'EEM_Message_Template' => 'load_model', |
765 | 765 | //load_helper |
766 | - 'EEH_Parse_Shortcodes' => function () { |
|
766 | + 'EEH_Parse_Shortcodes' => function() { |
|
767 | 767 | if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
768 | 768 | return new EEH_Parse_Shortcodes(); |
769 | 769 | } |
770 | 770 | return null; |
771 | 771 | }, |
772 | - 'EE_Template_Config' => function () { |
|
772 | + 'EE_Template_Config' => function() { |
|
773 | 773 | return EE_Config::instance()->template_settings; |
774 | 774 | }, |
775 | - 'EE_Currency_Config' => function () { |
|
775 | + 'EE_Currency_Config' => function() { |
|
776 | 776 | return EE_Config::instance()->currency; |
777 | 777 | }, |
778 | - 'EE_Registration_Config' => function () { |
|
778 | + 'EE_Registration_Config' => function() { |
|
779 | 779 | return EE_Config::instance()->registration; |
780 | 780 | }, |
781 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
781 | + 'EventEspresso\core\services\loaders\Loader' => function() { |
|
782 | 782 | return LoaderFactory::getLoader(); |
783 | 783 | }, |
784 | 784 | ); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
835 | 835 | 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
836 | 836 | ); |
837 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
837 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
838 | 838 | $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
839 | 839 | } |
840 | 840 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EventEspresso\core\services\request\ResponseInterface; |
9 | 9 | |
10 | 10 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
11 | - exit('No direct script access allowed'); |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -25,843 +25,843 @@ discard block |
||
25 | 25 | class EE_Dependency_Map |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * This means that the requested class dependency is not present in the dependency map |
|
30 | - */ |
|
31 | - const not_registered = 0; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
35 | - */ |
|
36 | - const load_new_object = 1; |
|
37 | - |
|
38 | - /** |
|
39 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
40 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
41 | - */ |
|
42 | - const load_from_cache = 2; |
|
43 | - |
|
44 | - /** |
|
45 | - * When registering a dependency, |
|
46 | - * this indicates to keep any existing dependencies that already exist, |
|
47 | - * and simply discard any new dependencies declared in the incoming data |
|
48 | - */ |
|
49 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
50 | - |
|
51 | - /** |
|
52 | - * When registering a dependency, |
|
53 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
54 | - */ |
|
55 | - const OVERWRITE_DEPENDENCIES = 1; |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @type EE_Dependency_Map $_instance |
|
61 | - */ |
|
62 | - protected static $_instance; |
|
63 | - |
|
64 | - /** |
|
65 | - * @type RequestInterface $request |
|
66 | - */ |
|
67 | - protected $request; |
|
68 | - |
|
69 | - /** |
|
70 | - * @type LegacyRequestInterface $legacy_request |
|
71 | - */ |
|
72 | - protected $legacy_request; |
|
73 | - |
|
74 | - /** |
|
75 | - * @type ResponseInterface $response |
|
76 | - */ |
|
77 | - protected $response; |
|
78 | - |
|
79 | - /** |
|
80 | - * @type LoaderInterface $loader |
|
81 | - */ |
|
82 | - protected $loader; |
|
83 | - |
|
84 | - /** |
|
85 | - * @type array $_dependency_map |
|
86 | - */ |
|
87 | - protected $_dependency_map = array(); |
|
88 | - |
|
89 | - /** |
|
90 | - * @type array $_class_loaders |
|
91 | - */ |
|
92 | - protected $_class_loaders = array(); |
|
93 | - |
|
94 | - /** |
|
95 | - * @type array $_aliases |
|
96 | - */ |
|
97 | - protected $_aliases = array(); |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * EE_Dependency_Map constructor. |
|
103 | - */ |
|
104 | - protected function __construct() |
|
105 | - { |
|
106 | - // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
107 | - do_action('EE_Dependency_Map____construct'); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * @throws InvalidDataTypeException |
|
114 | - * @throws InvalidInterfaceException |
|
115 | - * @throws InvalidArgumentException |
|
116 | - */ |
|
117 | - public function initialize() |
|
118 | - { |
|
119 | - $this->_register_core_dependencies(); |
|
120 | - $this->_register_core_class_loaders(); |
|
121 | - $this->_register_core_aliases(); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @singleton method used to instantiate class object |
|
128 | - * @return EE_Dependency_Map |
|
129 | - */ |
|
130 | - public static function instance() { |
|
131 | - // check if class object is instantiated, and instantiated properly |
|
132 | - if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | - self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
134 | - } |
|
135 | - return self::$_instance; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param RequestInterface $request |
|
141 | - */ |
|
142 | - public function setRequest(RequestInterface $request) |
|
143 | - { |
|
144 | - $this->request = $request; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @param LegacyRequestInterface $legacy_request |
|
150 | - */ |
|
151 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
152 | - { |
|
153 | - $this->legacy_request = $legacy_request; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param ResponseInterface $response |
|
159 | - */ |
|
160 | - public function setResponse(ResponseInterface $response) |
|
161 | - { |
|
162 | - $this->response = $response; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @param LoaderInterface $loader |
|
169 | - */ |
|
170 | - public function setLoader(LoaderInterface $loader) |
|
171 | - { |
|
172 | - $this->loader = $loader; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string $class |
|
179 | - * @param array $dependencies |
|
180 | - * @param int $overwrite |
|
181 | - * @return bool |
|
182 | - */ |
|
183 | - public static function register_dependencies( |
|
184 | - $class, |
|
185 | - array $dependencies, |
|
186 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
187 | - ) { |
|
188 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
195 | - * to the class specified by the first parameter. |
|
196 | - * IMPORTANT !!! |
|
197 | - * The order of elements in the incoming $dependencies array MUST match |
|
198 | - * the order of the constructor parameters for the class in question. |
|
199 | - * This is especially important when overriding any existing dependencies that are registered. |
|
200 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
201 | - * |
|
202 | - * @param string $class |
|
203 | - * @param array $dependencies |
|
204 | - * @param int $overwrite |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function registerDependencies( |
|
208 | - $class, |
|
209 | - array $dependencies, |
|
210 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
211 | - ) { |
|
212 | - $class = trim($class, '\\'); |
|
213 | - $registered = false; |
|
214 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
216 | - } |
|
217 | - // we need to make sure that any aliases used when registering a dependency |
|
218 | - // get resolved to the correct class name |
|
219 | - foreach ($dependencies as $dependency => $load_source) { |
|
220 | - $alias = self::$_instance->get_alias($dependency); |
|
221 | - if ( |
|
222 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
223 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
224 | - ) { |
|
225 | - unset($dependencies[$dependency]); |
|
226 | - $dependencies[$alias] = $load_source; |
|
227 | - $registered = true; |
|
228 | - } |
|
229 | - } |
|
230 | - // now add our two lists of dependencies together. |
|
231 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
232 | - // so $dependencies is NOT overwritten because it is listed first |
|
233 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
234 | - // Union is way faster than array_merge() but should be used with caution... |
|
235 | - // especially with numerically indexed arrays |
|
236 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
237 | - // now we need to ensure that the resulting dependencies |
|
238 | - // array only has the entries that are required for the class |
|
239 | - // so first count how many dependencies were originally registered for the class |
|
240 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
241 | - // if that count is non-zero (meaning dependencies were already registered) |
|
242 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
243 | - // then truncate the final array to match that count |
|
244 | - ? array_slice($dependencies, 0, $dependency_count) |
|
245 | - // otherwise just take the incoming array because nothing previously existed |
|
246 | - : $dependencies; |
|
247 | - return $registered; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @param string $class_name |
|
254 | - * @param string $loader |
|
255 | - * @return bool |
|
256 | - * @throws DomainException |
|
257 | - */ |
|
258 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
259 | - { |
|
260 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | - throw new DomainException( |
|
262 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
263 | - ); |
|
264 | - } |
|
265 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
266 | - if ( |
|
267 | - ! is_callable($loader) |
|
268 | - && ( |
|
269 | - strpos($loader, 'load_') !== 0 |
|
270 | - || ! method_exists('EE_Registry', $loader) |
|
271 | - ) |
|
272 | - ) { |
|
273 | - throw new DomainException( |
|
274 | - sprintf( |
|
275 | - esc_html__( |
|
276 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
277 | - 'event_espresso' |
|
278 | - ), |
|
279 | - $loader |
|
280 | - ) |
|
281 | - ); |
|
282 | - } |
|
283 | - $class_name = self::$_instance->get_alias($class_name); |
|
284 | - if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | - self::$_instance->_class_loaders[$class_name] = $loader; |
|
286 | - return true; |
|
287 | - } |
|
288 | - return false; |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * @return array |
|
295 | - */ |
|
296 | - public function dependency_map() |
|
297 | - { |
|
298 | - return $this->_dependency_map; |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
305 | - * |
|
306 | - * @param string $class_name |
|
307 | - * @return boolean |
|
308 | - */ |
|
309 | - public function has($class_name = '') |
|
310 | - { |
|
311 | - // all legacy models have the same dependencies |
|
312 | - if (strpos($class_name, 'EEM_') === 0) { |
|
313 | - $class_name = 'LEGACY_MODELS'; |
|
314 | - } |
|
315 | - return isset($this->_dependency_map[$class_name]) ? true : false; |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
322 | - * |
|
323 | - * @param string $class_name |
|
324 | - * @param string $dependency |
|
325 | - * @return bool |
|
326 | - */ |
|
327 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
328 | - { |
|
329 | - // all legacy models have the same dependencies |
|
330 | - if (strpos($class_name, 'EEM_') === 0) { |
|
331 | - $class_name = 'LEGACY_MODELS'; |
|
332 | - } |
|
333 | - $dependency = $this->get_alias($dependency); |
|
334 | - return isset($this->_dependency_map[$class_name][$dependency]) |
|
335 | - ? true |
|
336 | - : false; |
|
337 | - } |
|
338 | - |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | - * |
|
344 | - * @param string $class_name |
|
345 | - * @param string $dependency |
|
346 | - * @return int |
|
347 | - */ |
|
348 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | - { |
|
350 | - // all legacy models have the same dependencies |
|
351 | - if (strpos($class_name, 'EEM_') === 0) { |
|
352 | - $class_name = 'LEGACY_MODELS'; |
|
353 | - } |
|
354 | - $dependency = $this->get_alias($dependency); |
|
355 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | - ? $this->_dependency_map[$class_name][$dependency] |
|
357 | - : EE_Dependency_Map::not_registered; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param string $class_name |
|
364 | - * @return string | Closure |
|
365 | - */ |
|
366 | - public function class_loader($class_name) |
|
367 | - { |
|
368 | - // all legacy models use load_model() |
|
369 | - if(strpos($class_name, 'EEM_') === 0){ |
|
370 | - return 'load_model'; |
|
371 | - } |
|
372 | - $class_name = $this->get_alias($class_name); |
|
373 | - return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * @return array |
|
380 | - */ |
|
381 | - public function class_loaders() |
|
382 | - { |
|
383 | - return $this->_class_loaders; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * adds an alias for a classname |
|
390 | - * |
|
391 | - * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
392 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
393 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
394 | - */ |
|
395 | - public function add_alias($class_name, $alias, $for_class = '') |
|
396 | - { |
|
397 | - if ($for_class !== '') { |
|
398 | - if (! isset($this->_aliases[$for_class])) { |
|
399 | - $this->_aliases[$for_class] = array(); |
|
400 | - } |
|
401 | - $this->_aliases[$for_class][$class_name] = $alias; |
|
402 | - } |
|
403 | - $this->_aliases[$class_name] = $alias; |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * returns TRUE if the provided class name has an alias |
|
410 | - * |
|
411 | - * @param string $class_name |
|
412 | - * @param string $for_class |
|
413 | - * @return bool |
|
414 | - */ |
|
415 | - public function has_alias($class_name = '', $for_class = '') |
|
416 | - { |
|
417 | - return isset($this->_aliases[$for_class][$class_name]) |
|
418 | - || ( |
|
419 | - isset($this->_aliases[$class_name]) |
|
420 | - && ! is_array($this->_aliases[$class_name]) |
|
421 | - ); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * returns alias for class name if one exists, otherwise returns the original classname |
|
428 | - * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
429 | - * for example: |
|
430 | - * if the following two entries were added to the _aliases array: |
|
431 | - * array( |
|
432 | - * 'interface_alias' => 'some\namespace\interface' |
|
433 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
434 | - * ) |
|
435 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
436 | - * to load an instance of 'some\namespace\classname' |
|
437 | - * |
|
438 | - * @param string $class_name |
|
439 | - * @param string $for_class |
|
440 | - * @return string |
|
441 | - */ |
|
442 | - public function get_alias($class_name = '', $for_class = '') |
|
443 | - { |
|
444 | - if (! $this->has_alias($class_name, $for_class)) { |
|
445 | - return $class_name; |
|
446 | - } |
|
447 | - if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
448 | - return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
449 | - } |
|
450 | - return $this->get_alias($this->_aliases[$class_name]); |
|
451 | - } |
|
452 | - |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
457 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
458 | - * This is done by using the following class constants: |
|
459 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
460 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
461 | - */ |
|
462 | - protected function _register_core_dependencies() |
|
463 | - { |
|
464 | - $this->_dependency_map = array( |
|
465 | - 'EE_Request_Handler' => array( |
|
466 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
467 | - ), |
|
468 | - 'EE_System' => array( |
|
469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
473 | - ), |
|
474 | - 'EE_Session' => array( |
|
475 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
476 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
477 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
478 | - ), |
|
479 | - 'EE_Cart' => array( |
|
480 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
481 | - ), |
|
482 | - 'EE_Front_Controller' => array( |
|
483 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
484 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
485 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
486 | - ), |
|
487 | - 'EE_Messenger_Collection_Loader' => array( |
|
488 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
489 | - ), |
|
490 | - 'EE_Message_Type_Collection_Loader' => array( |
|
491 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
492 | - ), |
|
493 | - 'EE_Message_Resource_Manager' => array( |
|
494 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
495 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
496 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
497 | - ), |
|
498 | - 'EE_Message_Factory' => array( |
|
499 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
500 | - ), |
|
501 | - 'EE_messages' => array( |
|
502 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
503 | - ), |
|
504 | - 'EE_Messages_Generator' => array( |
|
505 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
506 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
507 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
508 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
509 | - ), |
|
510 | - 'EE_Messages_Processor' => array( |
|
511 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | - ), |
|
513 | - 'EE_Messages_Queue' => array( |
|
514 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
515 | - ), |
|
516 | - 'EE_Messages_Template_Defaults' => array( |
|
517 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
518 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
519 | - ), |
|
520 | - 'EE_Message_To_Generate_From_Request' => array( |
|
521 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
523 | - ), |
|
524 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
525 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
526 | - ), |
|
527 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
528 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
529 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
530 | - ), |
|
531 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
532 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | - ), |
|
534 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
535 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
536 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
537 | - ), |
|
538 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
539 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
540 | - ), |
|
541 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
542 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
543 | - ), |
|
544 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
545 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
546 | - ), |
|
547 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
548 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
549 | - ), |
|
550 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
551 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
552 | - ), |
|
553 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
554 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
555 | - ), |
|
556 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
557 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
558 | - ), |
|
559 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
560 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
561 | - ), |
|
562 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
563 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
564 | - ), |
|
565 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
566 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
567 | - ), |
|
568 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
569 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
570 | - ), |
|
571 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
572 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
573 | - ), |
|
574 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
575 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
576 | - ), |
|
577 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | - ), |
|
580 | - 'EE_Data_Migration_Class_Base' => array( |
|
581 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
582 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
583 | - ), |
|
584 | - 'EE_DMS_Core_4_1_0' => array( |
|
585 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | - ), |
|
588 | - 'EE_DMS_Core_4_2_0' => array( |
|
589 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | - ), |
|
592 | - 'EE_DMS_Core_4_3_0' => array( |
|
593 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | - ), |
|
596 | - 'EE_DMS_Core_4_4_0' => array( |
|
597 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | - ), |
|
600 | - 'EE_DMS_Core_4_5_0' => array( |
|
601 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | - ), |
|
604 | - 'EE_DMS_Core_4_6_0' => array( |
|
605 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | - ), |
|
608 | - 'EE_DMS_Core_4_7_0' => array( |
|
609 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | - ), |
|
612 | - 'EE_DMS_Core_4_8_0' => array( |
|
613 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | - ), |
|
616 | - 'EE_DMS_Core_4_9_0' => array( |
|
617 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | - ), |
|
620 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
621 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
622 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
623 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
624 | - ), |
|
625 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
626 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - ), |
|
628 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
629 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | - ), |
|
631 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
632 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | - ), |
|
634 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | - ), |
|
637 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
638 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | - ), |
|
640 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
641 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | - ), |
|
643 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
644 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
645 | - ), |
|
646 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
647 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | - ), |
|
649 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
650 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
651 | - ), |
|
652 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
653 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
654 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
655 | - ), |
|
656 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
657 | - null, |
|
658 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
659 | - ), |
|
660 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
661 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
662 | - ), |
|
663 | - 'LEGACY_MODELS' => array( |
|
664 | - null, |
|
665 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
666 | - ), |
|
667 | - 'EE_Module_Request_Router' => array( |
|
668 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
669 | - ), |
|
670 | - 'EE_Registration_Processor' => array( |
|
671 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
672 | - ), |
|
673 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
674 | - null, |
|
675 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
677 | - ), |
|
678 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
679 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
681 | - ), |
|
682 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
683 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
684 | - ), |
|
685 | - ); |
|
686 | - } |
|
687 | - |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * Registers how core classes are loaded. |
|
692 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
693 | - * 'EE_Request_Handler' => 'load_core' |
|
694 | - * 'EE_Messages_Queue' => 'load_lib' |
|
695 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
696 | - * or, if greater control is required, by providing a custom closure. For example: |
|
697 | - * 'Some_Class' => function () { |
|
698 | - * return new Some_Class(); |
|
699 | - * }, |
|
700 | - * This is required for instantiating dependencies |
|
701 | - * where an interface has been type hinted in a class constructor. For example: |
|
702 | - * 'Required_Interface' => function () { |
|
703 | - * return new A_Class_That_Implements_Required_Interface(); |
|
704 | - * }, |
|
705 | - * |
|
706 | - * @throws InvalidInterfaceException |
|
707 | - * @throws InvalidDataTypeException |
|
708 | - * @throws InvalidArgumentException |
|
709 | - */ |
|
710 | - protected function _register_core_class_loaders() |
|
711 | - { |
|
712 | - //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
713 | - //be used in a closure. |
|
714 | - $request = &$this->request; |
|
715 | - $response = &$this->response; |
|
716 | - $legacy_request = &$this->legacy_request; |
|
717 | - // $loader = &$this->loader; |
|
718 | - $this->_class_loaders = array( |
|
719 | - //load_core |
|
720 | - 'EE_Capabilities' => 'load_core', |
|
721 | - 'EE_Encryption' => 'load_core', |
|
722 | - 'EE_Front_Controller' => 'load_core', |
|
723 | - 'EE_Module_Request_Router' => 'load_core', |
|
724 | - 'EE_Registry' => 'load_core', |
|
725 | - 'EE_Request' => function () use (&$legacy_request) { |
|
726 | - return $legacy_request; |
|
727 | - }, |
|
728 | - 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
729 | - return $request; |
|
730 | - }, |
|
731 | - 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
732 | - return $response; |
|
733 | - }, |
|
734 | - 'EE_Request_Handler' => 'load_core', |
|
735 | - 'EE_Session' => 'load_core', |
|
736 | - 'EE_Cron_Tasks' => 'load_core', |
|
737 | - 'EE_System' => 'load_core', |
|
738 | - 'EE_Maintenance_Mode' => 'load_core', |
|
739 | - 'EE_Register_CPTs' => 'load_core', |
|
740 | - 'EE_Admin' => 'load_core', |
|
741 | - //load_lib |
|
742 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
743 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
744 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
745 | - 'EE_Messenger_Collection' => 'load_lib', |
|
746 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
747 | - 'EE_Messages_Processor' => 'load_lib', |
|
748 | - 'EE_Message_Repository' => 'load_lib', |
|
749 | - 'EE_Messages_Queue' => 'load_lib', |
|
750 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
751 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
752 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
753 | - 'EE_Messages_Generator' => function () { |
|
754 | - return EE_Registry::instance()->load_lib( |
|
755 | - 'Messages_Generator', |
|
756 | - array(), |
|
757 | - false, |
|
758 | - false |
|
759 | - ); |
|
760 | - }, |
|
761 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
762 | - return EE_Registry::instance()->load_lib( |
|
763 | - 'Messages_Template_Defaults', |
|
764 | - $arguments, |
|
765 | - false, |
|
766 | - false |
|
767 | - ); |
|
768 | - }, |
|
769 | - //load_model |
|
770 | - // 'EEM_Attendee' => 'load_model', |
|
771 | - // 'EEM_Message_Template_Group' => 'load_model', |
|
772 | - // 'EEM_Message_Template' => 'load_model', |
|
773 | - //load_helper |
|
774 | - 'EEH_Parse_Shortcodes' => function () { |
|
775 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
776 | - return new EEH_Parse_Shortcodes(); |
|
777 | - } |
|
778 | - return null; |
|
779 | - }, |
|
780 | - 'EE_Template_Config' => function () { |
|
781 | - return EE_Config::instance()->template_settings; |
|
782 | - }, |
|
783 | - 'EE_Currency_Config' => function () { |
|
784 | - return EE_Config::instance()->currency; |
|
785 | - }, |
|
786 | - 'EE_Registration_Config' => function () { |
|
787 | - return EE_Config::instance()->registration; |
|
788 | - }, |
|
789 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
790 | - return LoaderFactory::getLoader(); |
|
791 | - }, |
|
792 | - ); |
|
793 | - } |
|
794 | - |
|
795 | - |
|
796 | - |
|
797 | - /** |
|
798 | - * can be used for supplying alternate names for classes, |
|
799 | - * or for connecting interface names to instantiable classes |
|
800 | - */ |
|
801 | - protected function _register_core_aliases() |
|
802 | - { |
|
803 | - $this->_aliases = array( |
|
804 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
805 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
806 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
807 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
808 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
809 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
810 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
811 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
812 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
813 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
814 | - 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
815 | - 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
816 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
817 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
818 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
819 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
820 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
821 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
822 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
823 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
824 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
825 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
826 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
827 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
828 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
829 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
830 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
831 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
832 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
833 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
834 | - 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
835 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
836 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
837 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
838 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
839 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
840 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
841 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
842 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
843 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
844 | - ); |
|
845 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
846 | - $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
847 | - } |
|
848 | - } |
|
849 | - |
|
850 | - |
|
851 | - |
|
852 | - /** |
|
853 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
854 | - * request Primarily used by unit tests. |
|
855 | - * |
|
856 | - * @throws InvalidDataTypeException |
|
857 | - * @throws InvalidInterfaceException |
|
858 | - * @throws InvalidArgumentException |
|
859 | - */ |
|
860 | - public function reset() |
|
861 | - { |
|
862 | - $this->_register_core_class_loaders(); |
|
863 | - $this->_register_core_dependencies(); |
|
864 | - } |
|
28 | + /** |
|
29 | + * This means that the requested class dependency is not present in the dependency map |
|
30 | + */ |
|
31 | + const not_registered = 0; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
35 | + */ |
|
36 | + const load_new_object = 1; |
|
37 | + |
|
38 | + /** |
|
39 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
40 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
41 | + */ |
|
42 | + const load_from_cache = 2; |
|
43 | + |
|
44 | + /** |
|
45 | + * When registering a dependency, |
|
46 | + * this indicates to keep any existing dependencies that already exist, |
|
47 | + * and simply discard any new dependencies declared in the incoming data |
|
48 | + */ |
|
49 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
50 | + |
|
51 | + /** |
|
52 | + * When registering a dependency, |
|
53 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
54 | + */ |
|
55 | + const OVERWRITE_DEPENDENCIES = 1; |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @type EE_Dependency_Map $_instance |
|
61 | + */ |
|
62 | + protected static $_instance; |
|
63 | + |
|
64 | + /** |
|
65 | + * @type RequestInterface $request |
|
66 | + */ |
|
67 | + protected $request; |
|
68 | + |
|
69 | + /** |
|
70 | + * @type LegacyRequestInterface $legacy_request |
|
71 | + */ |
|
72 | + protected $legacy_request; |
|
73 | + |
|
74 | + /** |
|
75 | + * @type ResponseInterface $response |
|
76 | + */ |
|
77 | + protected $response; |
|
78 | + |
|
79 | + /** |
|
80 | + * @type LoaderInterface $loader |
|
81 | + */ |
|
82 | + protected $loader; |
|
83 | + |
|
84 | + /** |
|
85 | + * @type array $_dependency_map |
|
86 | + */ |
|
87 | + protected $_dependency_map = array(); |
|
88 | + |
|
89 | + /** |
|
90 | + * @type array $_class_loaders |
|
91 | + */ |
|
92 | + protected $_class_loaders = array(); |
|
93 | + |
|
94 | + /** |
|
95 | + * @type array $_aliases |
|
96 | + */ |
|
97 | + protected $_aliases = array(); |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * EE_Dependency_Map constructor. |
|
103 | + */ |
|
104 | + protected function __construct() |
|
105 | + { |
|
106 | + // add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
107 | + do_action('EE_Dependency_Map____construct'); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * @throws InvalidDataTypeException |
|
114 | + * @throws InvalidInterfaceException |
|
115 | + * @throws InvalidArgumentException |
|
116 | + */ |
|
117 | + public function initialize() |
|
118 | + { |
|
119 | + $this->_register_core_dependencies(); |
|
120 | + $this->_register_core_class_loaders(); |
|
121 | + $this->_register_core_aliases(); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @singleton method used to instantiate class object |
|
128 | + * @return EE_Dependency_Map |
|
129 | + */ |
|
130 | + public static function instance() { |
|
131 | + // check if class object is instantiated, and instantiated properly |
|
132 | + if (! self::$_instance instanceof EE_Dependency_Map) { |
|
133 | + self::$_instance = new EE_Dependency_Map(/*$request, $response, $legacy_request*/); |
|
134 | + } |
|
135 | + return self::$_instance; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param RequestInterface $request |
|
141 | + */ |
|
142 | + public function setRequest(RequestInterface $request) |
|
143 | + { |
|
144 | + $this->request = $request; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @param LegacyRequestInterface $legacy_request |
|
150 | + */ |
|
151 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
152 | + { |
|
153 | + $this->legacy_request = $legacy_request; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param ResponseInterface $response |
|
159 | + */ |
|
160 | + public function setResponse(ResponseInterface $response) |
|
161 | + { |
|
162 | + $this->response = $response; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @param LoaderInterface $loader |
|
169 | + */ |
|
170 | + public function setLoader(LoaderInterface $loader) |
|
171 | + { |
|
172 | + $this->loader = $loader; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string $class |
|
179 | + * @param array $dependencies |
|
180 | + * @param int $overwrite |
|
181 | + * @return bool |
|
182 | + */ |
|
183 | + public static function register_dependencies( |
|
184 | + $class, |
|
185 | + array $dependencies, |
|
186 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
187 | + ) { |
|
188 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
195 | + * to the class specified by the first parameter. |
|
196 | + * IMPORTANT !!! |
|
197 | + * The order of elements in the incoming $dependencies array MUST match |
|
198 | + * the order of the constructor parameters for the class in question. |
|
199 | + * This is especially important when overriding any existing dependencies that are registered. |
|
200 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
201 | + * |
|
202 | + * @param string $class |
|
203 | + * @param array $dependencies |
|
204 | + * @param int $overwrite |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function registerDependencies( |
|
208 | + $class, |
|
209 | + array $dependencies, |
|
210 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
211 | + ) { |
|
212 | + $class = trim($class, '\\'); |
|
213 | + $registered = false; |
|
214 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
215 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
216 | + } |
|
217 | + // we need to make sure that any aliases used when registering a dependency |
|
218 | + // get resolved to the correct class name |
|
219 | + foreach ($dependencies as $dependency => $load_source) { |
|
220 | + $alias = self::$_instance->get_alias($dependency); |
|
221 | + if ( |
|
222 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
223 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
224 | + ) { |
|
225 | + unset($dependencies[$dependency]); |
|
226 | + $dependencies[$alias] = $load_source; |
|
227 | + $registered = true; |
|
228 | + } |
|
229 | + } |
|
230 | + // now add our two lists of dependencies together. |
|
231 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
232 | + // so $dependencies is NOT overwritten because it is listed first |
|
233 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
234 | + // Union is way faster than array_merge() but should be used with caution... |
|
235 | + // especially with numerically indexed arrays |
|
236 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
237 | + // now we need to ensure that the resulting dependencies |
|
238 | + // array only has the entries that are required for the class |
|
239 | + // so first count how many dependencies were originally registered for the class |
|
240 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
241 | + // if that count is non-zero (meaning dependencies were already registered) |
|
242 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
243 | + // then truncate the final array to match that count |
|
244 | + ? array_slice($dependencies, 0, $dependency_count) |
|
245 | + // otherwise just take the incoming array because nothing previously existed |
|
246 | + : $dependencies; |
|
247 | + return $registered; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @param string $class_name |
|
254 | + * @param string $loader |
|
255 | + * @return bool |
|
256 | + * @throws DomainException |
|
257 | + */ |
|
258 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
259 | + { |
|
260 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
261 | + throw new DomainException( |
|
262 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
263 | + ); |
|
264 | + } |
|
265 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
266 | + if ( |
|
267 | + ! is_callable($loader) |
|
268 | + && ( |
|
269 | + strpos($loader, 'load_') !== 0 |
|
270 | + || ! method_exists('EE_Registry', $loader) |
|
271 | + ) |
|
272 | + ) { |
|
273 | + throw new DomainException( |
|
274 | + sprintf( |
|
275 | + esc_html__( |
|
276 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
277 | + 'event_espresso' |
|
278 | + ), |
|
279 | + $loader |
|
280 | + ) |
|
281 | + ); |
|
282 | + } |
|
283 | + $class_name = self::$_instance->get_alias($class_name); |
|
284 | + if (! isset(self::$_instance->_class_loaders[$class_name])) { |
|
285 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
286 | + return true; |
|
287 | + } |
|
288 | + return false; |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * @return array |
|
295 | + */ |
|
296 | + public function dependency_map() |
|
297 | + { |
|
298 | + return $this->_dependency_map; |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
305 | + * |
|
306 | + * @param string $class_name |
|
307 | + * @return boolean |
|
308 | + */ |
|
309 | + public function has($class_name = '') |
|
310 | + { |
|
311 | + // all legacy models have the same dependencies |
|
312 | + if (strpos($class_name, 'EEM_') === 0) { |
|
313 | + $class_name = 'LEGACY_MODELS'; |
|
314 | + } |
|
315 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
322 | + * |
|
323 | + * @param string $class_name |
|
324 | + * @param string $dependency |
|
325 | + * @return bool |
|
326 | + */ |
|
327 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
328 | + { |
|
329 | + // all legacy models have the same dependencies |
|
330 | + if (strpos($class_name, 'EEM_') === 0) { |
|
331 | + $class_name = 'LEGACY_MODELS'; |
|
332 | + } |
|
333 | + $dependency = $this->get_alias($dependency); |
|
334 | + return isset($this->_dependency_map[$class_name][$dependency]) |
|
335 | + ? true |
|
336 | + : false; |
|
337 | + } |
|
338 | + |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | + * |
|
344 | + * @param string $class_name |
|
345 | + * @param string $dependency |
|
346 | + * @return int |
|
347 | + */ |
|
348 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | + { |
|
350 | + // all legacy models have the same dependencies |
|
351 | + if (strpos($class_name, 'EEM_') === 0) { |
|
352 | + $class_name = 'LEGACY_MODELS'; |
|
353 | + } |
|
354 | + $dependency = $this->get_alias($dependency); |
|
355 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | + ? $this->_dependency_map[$class_name][$dependency] |
|
357 | + : EE_Dependency_Map::not_registered; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param string $class_name |
|
364 | + * @return string | Closure |
|
365 | + */ |
|
366 | + public function class_loader($class_name) |
|
367 | + { |
|
368 | + // all legacy models use load_model() |
|
369 | + if(strpos($class_name, 'EEM_') === 0){ |
|
370 | + return 'load_model'; |
|
371 | + } |
|
372 | + $class_name = $this->get_alias($class_name); |
|
373 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * @return array |
|
380 | + */ |
|
381 | + public function class_loaders() |
|
382 | + { |
|
383 | + return $this->_class_loaders; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * adds an alias for a classname |
|
390 | + * |
|
391 | + * @param string $class_name the class name that should be used (concrete class to replace interface) |
|
392 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
393 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
394 | + */ |
|
395 | + public function add_alias($class_name, $alias, $for_class = '') |
|
396 | + { |
|
397 | + if ($for_class !== '') { |
|
398 | + if (! isset($this->_aliases[$for_class])) { |
|
399 | + $this->_aliases[$for_class] = array(); |
|
400 | + } |
|
401 | + $this->_aliases[$for_class][$class_name] = $alias; |
|
402 | + } |
|
403 | + $this->_aliases[$class_name] = $alias; |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * returns TRUE if the provided class name has an alias |
|
410 | + * |
|
411 | + * @param string $class_name |
|
412 | + * @param string $for_class |
|
413 | + * @return bool |
|
414 | + */ |
|
415 | + public function has_alias($class_name = '', $for_class = '') |
|
416 | + { |
|
417 | + return isset($this->_aliases[$for_class][$class_name]) |
|
418 | + || ( |
|
419 | + isset($this->_aliases[$class_name]) |
|
420 | + && ! is_array($this->_aliases[$class_name]) |
|
421 | + ); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * returns alias for class name if one exists, otherwise returns the original classname |
|
428 | + * functions recursively, so that multiple aliases can be used to drill down to a classname |
|
429 | + * for example: |
|
430 | + * if the following two entries were added to the _aliases array: |
|
431 | + * array( |
|
432 | + * 'interface_alias' => 'some\namespace\interface' |
|
433 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
434 | + * ) |
|
435 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
436 | + * to load an instance of 'some\namespace\classname' |
|
437 | + * |
|
438 | + * @param string $class_name |
|
439 | + * @param string $for_class |
|
440 | + * @return string |
|
441 | + */ |
|
442 | + public function get_alias($class_name = '', $for_class = '') |
|
443 | + { |
|
444 | + if (! $this->has_alias($class_name, $for_class)) { |
|
445 | + return $class_name; |
|
446 | + } |
|
447 | + if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
|
448 | + return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
|
449 | + } |
|
450 | + return $this->get_alias($this->_aliases[$class_name]); |
|
451 | + } |
|
452 | + |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
457 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
458 | + * This is done by using the following class constants: |
|
459 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
460 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
461 | + */ |
|
462 | + protected function _register_core_dependencies() |
|
463 | + { |
|
464 | + $this->_dependency_map = array( |
|
465 | + 'EE_Request_Handler' => array( |
|
466 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
467 | + ), |
|
468 | + 'EE_System' => array( |
|
469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
473 | + ), |
|
474 | + 'EE_Session' => array( |
|
475 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
476 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
477 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
478 | + ), |
|
479 | + 'EE_Cart' => array( |
|
480 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
481 | + ), |
|
482 | + 'EE_Front_Controller' => array( |
|
483 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
484 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
485 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
486 | + ), |
|
487 | + 'EE_Messenger_Collection_Loader' => array( |
|
488 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
489 | + ), |
|
490 | + 'EE_Message_Type_Collection_Loader' => array( |
|
491 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
492 | + ), |
|
493 | + 'EE_Message_Resource_Manager' => array( |
|
494 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
495 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
496 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
497 | + ), |
|
498 | + 'EE_Message_Factory' => array( |
|
499 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
500 | + ), |
|
501 | + 'EE_messages' => array( |
|
502 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
503 | + ), |
|
504 | + 'EE_Messages_Generator' => array( |
|
505 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
506 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
507 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
508 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
509 | + ), |
|
510 | + 'EE_Messages_Processor' => array( |
|
511 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
512 | + ), |
|
513 | + 'EE_Messages_Queue' => array( |
|
514 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
515 | + ), |
|
516 | + 'EE_Messages_Template_Defaults' => array( |
|
517 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
518 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
519 | + ), |
|
520 | + 'EE_Message_To_Generate_From_Request' => array( |
|
521 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
523 | + ), |
|
524 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
525 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
526 | + ), |
|
527 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
528 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
529 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
530 | + ), |
|
531 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
532 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | + ), |
|
534 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
535 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
536 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
537 | + ), |
|
538 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
539 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
540 | + ), |
|
541 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
542 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
543 | + ), |
|
544 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
545 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
546 | + ), |
|
547 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
548 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
549 | + ), |
|
550 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
551 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
552 | + ), |
|
553 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
554 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
555 | + ), |
|
556 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
557 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
558 | + ), |
|
559 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
560 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
561 | + ), |
|
562 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
563 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
564 | + ), |
|
565 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
566 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
567 | + ), |
|
568 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
569 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
570 | + ), |
|
571 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
572 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
573 | + ), |
|
574 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
575 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
576 | + ), |
|
577 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | + ), |
|
580 | + 'EE_Data_Migration_Class_Base' => array( |
|
581 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
582 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
583 | + ), |
|
584 | + 'EE_DMS_Core_4_1_0' => array( |
|
585 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
586 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
587 | + ), |
|
588 | + 'EE_DMS_Core_4_2_0' => array( |
|
589 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
590 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
591 | + ), |
|
592 | + 'EE_DMS_Core_4_3_0' => array( |
|
593 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
594 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
595 | + ), |
|
596 | + 'EE_DMS_Core_4_4_0' => array( |
|
597 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
598 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
599 | + ), |
|
600 | + 'EE_DMS_Core_4_5_0' => array( |
|
601 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
602 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
603 | + ), |
|
604 | + 'EE_DMS_Core_4_6_0' => array( |
|
605 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
606 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
607 | + ), |
|
608 | + 'EE_DMS_Core_4_7_0' => array( |
|
609 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
610 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
611 | + ), |
|
612 | + 'EE_DMS_Core_4_8_0' => array( |
|
613 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
614 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
615 | + ), |
|
616 | + 'EE_DMS_Core_4_9_0' => array( |
|
617 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
618 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
619 | + ), |
|
620 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
621 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
622 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
623 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache |
|
624 | + ), |
|
625 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
626 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + ), |
|
628 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
629 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
630 | + ), |
|
631 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
632 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
633 | + ), |
|
634 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
636 | + ), |
|
637 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
638 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
639 | + ), |
|
640 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
641 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
642 | + ), |
|
643 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
644 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
645 | + ), |
|
646 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
647 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
648 | + ), |
|
649 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
650 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
651 | + ), |
|
652 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
653 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
654 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
655 | + ), |
|
656 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
657 | + null, |
|
658 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
659 | + ), |
|
660 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
661 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
662 | + ), |
|
663 | + 'LEGACY_MODELS' => array( |
|
664 | + null, |
|
665 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
666 | + ), |
|
667 | + 'EE_Module_Request_Router' => array( |
|
668 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
669 | + ), |
|
670 | + 'EE_Registration_Processor' => array( |
|
671 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
672 | + ), |
|
673 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
674 | + null, |
|
675 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
677 | + ), |
|
678 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
679 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
681 | + ), |
|
682 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
683 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
684 | + ), |
|
685 | + ); |
|
686 | + } |
|
687 | + |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * Registers how core classes are loaded. |
|
692 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
693 | + * 'EE_Request_Handler' => 'load_core' |
|
694 | + * 'EE_Messages_Queue' => 'load_lib' |
|
695 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
696 | + * or, if greater control is required, by providing a custom closure. For example: |
|
697 | + * 'Some_Class' => function () { |
|
698 | + * return new Some_Class(); |
|
699 | + * }, |
|
700 | + * This is required for instantiating dependencies |
|
701 | + * where an interface has been type hinted in a class constructor. For example: |
|
702 | + * 'Required_Interface' => function () { |
|
703 | + * return new A_Class_That_Implements_Required_Interface(); |
|
704 | + * }, |
|
705 | + * |
|
706 | + * @throws InvalidInterfaceException |
|
707 | + * @throws InvalidDataTypeException |
|
708 | + * @throws InvalidArgumentException |
|
709 | + */ |
|
710 | + protected function _register_core_class_loaders() |
|
711 | + { |
|
712 | + //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot |
|
713 | + //be used in a closure. |
|
714 | + $request = &$this->request; |
|
715 | + $response = &$this->response; |
|
716 | + $legacy_request = &$this->legacy_request; |
|
717 | + // $loader = &$this->loader; |
|
718 | + $this->_class_loaders = array( |
|
719 | + //load_core |
|
720 | + 'EE_Capabilities' => 'load_core', |
|
721 | + 'EE_Encryption' => 'load_core', |
|
722 | + 'EE_Front_Controller' => 'load_core', |
|
723 | + 'EE_Module_Request_Router' => 'load_core', |
|
724 | + 'EE_Registry' => 'load_core', |
|
725 | + 'EE_Request' => function () use (&$legacy_request) { |
|
726 | + return $legacy_request; |
|
727 | + }, |
|
728 | + 'EventEspresso\core\services\request\Request' => function () use (&$request) { |
|
729 | + return $request; |
|
730 | + }, |
|
731 | + 'EventEspresso\core\services\request\Response' => function () use (&$response) { |
|
732 | + return $response; |
|
733 | + }, |
|
734 | + 'EE_Request_Handler' => 'load_core', |
|
735 | + 'EE_Session' => 'load_core', |
|
736 | + 'EE_Cron_Tasks' => 'load_core', |
|
737 | + 'EE_System' => 'load_core', |
|
738 | + 'EE_Maintenance_Mode' => 'load_core', |
|
739 | + 'EE_Register_CPTs' => 'load_core', |
|
740 | + 'EE_Admin' => 'load_core', |
|
741 | + //load_lib |
|
742 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
743 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
744 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
745 | + 'EE_Messenger_Collection' => 'load_lib', |
|
746 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
747 | + 'EE_Messages_Processor' => 'load_lib', |
|
748 | + 'EE_Message_Repository' => 'load_lib', |
|
749 | + 'EE_Messages_Queue' => 'load_lib', |
|
750 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
751 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
752 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
753 | + 'EE_Messages_Generator' => function () { |
|
754 | + return EE_Registry::instance()->load_lib( |
|
755 | + 'Messages_Generator', |
|
756 | + array(), |
|
757 | + false, |
|
758 | + false |
|
759 | + ); |
|
760 | + }, |
|
761 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
762 | + return EE_Registry::instance()->load_lib( |
|
763 | + 'Messages_Template_Defaults', |
|
764 | + $arguments, |
|
765 | + false, |
|
766 | + false |
|
767 | + ); |
|
768 | + }, |
|
769 | + //load_model |
|
770 | + // 'EEM_Attendee' => 'load_model', |
|
771 | + // 'EEM_Message_Template_Group' => 'load_model', |
|
772 | + // 'EEM_Message_Template' => 'load_model', |
|
773 | + //load_helper |
|
774 | + 'EEH_Parse_Shortcodes' => function () { |
|
775 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
776 | + return new EEH_Parse_Shortcodes(); |
|
777 | + } |
|
778 | + return null; |
|
779 | + }, |
|
780 | + 'EE_Template_Config' => function () { |
|
781 | + return EE_Config::instance()->template_settings; |
|
782 | + }, |
|
783 | + 'EE_Currency_Config' => function () { |
|
784 | + return EE_Config::instance()->currency; |
|
785 | + }, |
|
786 | + 'EE_Registration_Config' => function () { |
|
787 | + return EE_Config::instance()->registration; |
|
788 | + }, |
|
789 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
790 | + return LoaderFactory::getLoader(); |
|
791 | + }, |
|
792 | + ); |
|
793 | + } |
|
794 | + |
|
795 | + |
|
796 | + |
|
797 | + /** |
|
798 | + * can be used for supplying alternate names for classes, |
|
799 | + * or for connecting interface names to instantiable classes |
|
800 | + */ |
|
801 | + protected function _register_core_aliases() |
|
802 | + { |
|
803 | + $this->_aliases = array( |
|
804 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
805 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
806 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
807 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
808 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
809 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
810 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
811 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
812 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
813 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
814 | + 'CreateRegCodeCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand', |
|
815 | + 'CreateRegUrlLinkCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand', |
|
816 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
817 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
818 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
819 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
820 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
821 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
822 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
823 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
824 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
825 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
826 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
827 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
828 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
829 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
830 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
831 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
832 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
833 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
834 | + 'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session', |
|
835 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
836 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
837 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
838 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
839 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
840 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
841 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
842 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
843 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
844 | + ); |
|
845 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
846 | + $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices'; |
|
847 | + } |
|
848 | + } |
|
849 | + |
|
850 | + |
|
851 | + |
|
852 | + /** |
|
853 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
854 | + * request Primarily used by unit tests. |
|
855 | + * |
|
856 | + * @throws InvalidDataTypeException |
|
857 | + * @throws InvalidInterfaceException |
|
858 | + * @throws InvalidArgumentException |
|
859 | + */ |
|
860 | + public function reset() |
|
861 | + { |
|
862 | + $this->_register_core_class_loaders(); |
|
863 | + $this->_register_core_dependencies(); |
|
864 | + } |
|
865 | 865 | |
866 | 866 | |
867 | 867 | } |
@@ -19,33 +19,33 @@ |
||
19 | 19 | class InvalidRequestStackMiddlewareException extends InvalidDataTypeException |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param mixed $middleware_app_class |
|
24 | - * @param string $message |
|
25 | - * @param int $code |
|
26 | - * @param Exception $previous |
|
27 | - */ |
|
28 | - public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null) |
|
29 | - { |
|
30 | - if(is_array($middleware_app_class)) { |
|
31 | - $middleware_app_class = reset($middleware_app_class); |
|
32 | - } |
|
33 | - if (empty($message)) { |
|
34 | - $message = sprintf( |
|
35 | - esc_html__( |
|
36 | - 'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - $middleware_app_class |
|
40 | - ); |
|
41 | - } |
|
42 | - parent::__construct( |
|
43 | - '$middleware_app_class', |
|
44 | - $middleware_app_class, |
|
45 | - 'EventEspresso\core\services\request\middleware\Middleware', |
|
46 | - $message, |
|
47 | - $code, |
|
48 | - $previous |
|
49 | - ); |
|
50 | - } |
|
22 | + /** |
|
23 | + * @param mixed $middleware_app_class |
|
24 | + * @param string $message |
|
25 | + * @param int $code |
|
26 | + * @param Exception $previous |
|
27 | + */ |
|
28 | + public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null) |
|
29 | + { |
|
30 | + if(is_array($middleware_app_class)) { |
|
31 | + $middleware_app_class = reset($middleware_app_class); |
|
32 | + } |
|
33 | + if (empty($message)) { |
|
34 | + $message = sprintf( |
|
35 | + esc_html__( |
|
36 | + 'The supplied Request Stack Middleware class "%1$s" is invalid or could no be found.', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + $middleware_app_class |
|
40 | + ); |
|
41 | + } |
|
42 | + parent::__construct( |
|
43 | + '$middleware_app_class', |
|
44 | + $middleware_app_class, |
|
45 | + 'EventEspresso\core\services\request\middleware\Middleware', |
|
46 | + $message, |
|
47 | + $code, |
|
48 | + $previous |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | */ |
28 | 28 | public function __construct($middleware_app_class, $message = '', $code = 0, Exception $previous = null) |
29 | 29 | { |
30 | - if(is_array($middleware_app_class)) { |
|
30 | + if (is_array($middleware_app_class)) { |
|
31 | 31 | $middleware_app_class = reset($middleware_app_class); |
32 | 32 | } |
33 | 33 | if (empty($message)) { |
@@ -24,97 +24,97 @@ |
||
24 | 24 | class RequestStackBuilder extends SplDoublyLinkedList |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @type LoaderInterface $loader |
|
29 | - */ |
|
30 | - private $loader; |
|
27 | + /** |
|
28 | + * @type LoaderInterface $loader |
|
29 | + */ |
|
30 | + private $loader; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * RequestStackBuilder constructor. |
|
35 | - * |
|
36 | - * @param LoaderInterface $loader |
|
37 | - */ |
|
38 | - public function __construct(LoaderInterface $loader) |
|
39 | - { |
|
40 | - $this->loader = $loader; |
|
41 | - $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP); |
|
42 | - } |
|
33 | + /** |
|
34 | + * RequestStackBuilder constructor. |
|
35 | + * |
|
36 | + * @param LoaderInterface $loader |
|
37 | + */ |
|
38 | + public function __construct(LoaderInterface $loader) |
|
39 | + { |
|
40 | + $this->loader = $loader; |
|
41 | + $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO | SplDoublyLinkedList::IT_MODE_KEEP); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * builds decorated middleware stack |
|
47 | - * by continuously injecting previous middleware app into the next |
|
48 | - * |
|
49 | - * @param RequestStackCoreAppInterface $application |
|
50 | - * @return RequestStack |
|
51 | - * @throws Exception |
|
52 | - */ |
|
53 | - public function resolve(RequestStackCoreAppInterface $application) |
|
54 | - { |
|
55 | - $core_app = $application; |
|
56 | - // NOW... because the RequestStack is following the decorator pattern, |
|
57 | - // the first stack app we add will end up at the center of the stack, |
|
58 | - // and will end up being the last item to actually run, but we don't want that! |
|
59 | - // Basically we're dealing with TWO stacks, and transferring items from one to the other, |
|
60 | - // BUT... we want the final stack to be in the same order as the first. |
|
61 | - // So we need to reverse the iterator mode when transferring items, |
|
62 | - // because if we don't, the second stack will end up in the incorrect order. |
|
63 | - $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP); |
|
64 | - for ($this->rewind(); $this->valid(); $this->next()) { |
|
65 | - try { |
|
66 | - $middleware_app = $this->validateMiddlewareAppDetails($this->current(), true); |
|
67 | - $middleware_app_class = array_shift($middleware_app); |
|
68 | - $middleware_app_args = is_array($middleware_app) ? $middleware_app : array(); |
|
69 | - $middleware_app_args = array($application, $this->loader) + $middleware_app_args; |
|
70 | - $application = $this->loader->getShared($middleware_app_class, $middleware_app_args); |
|
71 | - } catch (InvalidRequestStackMiddlewareException $exception) { |
|
72 | - if(WP_DEBUG) { |
|
73 | - new ExceptionStackTraceDisplay($exception); |
|
74 | - continue; |
|
75 | - } |
|
76 | - error_log($exception->getMessage()); |
|
77 | - } |
|
78 | - } |
|
79 | - return new RequestStack($application, $core_app); |
|
80 | - } |
|
45 | + /** |
|
46 | + * builds decorated middleware stack |
|
47 | + * by continuously injecting previous middleware app into the next |
|
48 | + * |
|
49 | + * @param RequestStackCoreAppInterface $application |
|
50 | + * @return RequestStack |
|
51 | + * @throws Exception |
|
52 | + */ |
|
53 | + public function resolve(RequestStackCoreAppInterface $application) |
|
54 | + { |
|
55 | + $core_app = $application; |
|
56 | + // NOW... because the RequestStack is following the decorator pattern, |
|
57 | + // the first stack app we add will end up at the center of the stack, |
|
58 | + // and will end up being the last item to actually run, but we don't want that! |
|
59 | + // Basically we're dealing with TWO stacks, and transferring items from one to the other, |
|
60 | + // BUT... we want the final stack to be in the same order as the first. |
|
61 | + // So we need to reverse the iterator mode when transferring items, |
|
62 | + // because if we don't, the second stack will end up in the incorrect order. |
|
63 | + $this->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_KEEP); |
|
64 | + for ($this->rewind(); $this->valid(); $this->next()) { |
|
65 | + try { |
|
66 | + $middleware_app = $this->validateMiddlewareAppDetails($this->current(), true); |
|
67 | + $middleware_app_class = array_shift($middleware_app); |
|
68 | + $middleware_app_args = is_array($middleware_app) ? $middleware_app : array(); |
|
69 | + $middleware_app_args = array($application, $this->loader) + $middleware_app_args; |
|
70 | + $application = $this->loader->getShared($middleware_app_class, $middleware_app_args); |
|
71 | + } catch (InvalidRequestStackMiddlewareException $exception) { |
|
72 | + if(WP_DEBUG) { |
|
73 | + new ExceptionStackTraceDisplay($exception); |
|
74 | + continue; |
|
75 | + } |
|
76 | + error_log($exception->getMessage()); |
|
77 | + } |
|
78 | + } |
|
79 | + return new RequestStack($application, $core_app); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Ensures that the app details that have been pushed onto RequestStackBuilder |
|
85 | - * are all ordered correctly so that the middleware can be properly constructed |
|
86 | - * |
|
87 | - * @param array $middleware_app |
|
88 | - * @param bool $recurse |
|
89 | - * @return array |
|
90 | - * @throws InvalidRequestStackMiddlewareException |
|
91 | - */ |
|
92 | - protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false) |
|
93 | - { |
|
94 | - $middleware_app_class = reset($middleware_app); |
|
95 | - // is array empty ? |
|
96 | - if($middleware_app_class === false) { |
|
97 | - throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
98 | - } |
|
99 | - // are the class and arguments in the wrong order ? |
|
100 | - if(is_array($middleware_app_class)) { |
|
101 | - if ($recurse === true) { |
|
102 | - return $this->validateMiddlewareAppDetails(array_reverse($middleware_app)); |
|
103 | - } |
|
104 | - throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
105 | - } |
|
106 | - // is filter callback working like legacy middleware and sending a numerically indexed array ? |
|
107 | - if(is_int($middleware_app_class)) { |
|
108 | - if ($recurse === true) { |
|
109 | - $middleware_app = array_reverse($middleware_app); |
|
110 | - return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array())); |
|
111 | - } |
|
112 | - throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
113 | - } |
|
114 | - // is $middleware_app_class a valid FQCN (or class is already loaded) ? |
|
115 | - if(! class_exists($middleware_app_class)) { |
|
116 | - throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
117 | - } |
|
118 | - return $middleware_app; |
|
119 | - } |
|
83 | + /** |
|
84 | + * Ensures that the app details that have been pushed onto RequestStackBuilder |
|
85 | + * are all ordered correctly so that the middleware can be properly constructed |
|
86 | + * |
|
87 | + * @param array $middleware_app |
|
88 | + * @param bool $recurse |
|
89 | + * @return array |
|
90 | + * @throws InvalidRequestStackMiddlewareException |
|
91 | + */ |
|
92 | + protected function validateMiddlewareAppDetails(array $middleware_app, $recurse = false) |
|
93 | + { |
|
94 | + $middleware_app_class = reset($middleware_app); |
|
95 | + // is array empty ? |
|
96 | + if($middleware_app_class === false) { |
|
97 | + throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
98 | + } |
|
99 | + // are the class and arguments in the wrong order ? |
|
100 | + if(is_array($middleware_app_class)) { |
|
101 | + if ($recurse === true) { |
|
102 | + return $this->validateMiddlewareAppDetails(array_reverse($middleware_app)); |
|
103 | + } |
|
104 | + throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
105 | + } |
|
106 | + // is filter callback working like legacy middleware and sending a numerically indexed array ? |
|
107 | + if(is_int($middleware_app_class)) { |
|
108 | + if ($recurse === true) { |
|
109 | + $middleware_app = array_reverse($middleware_app); |
|
110 | + return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array())); |
|
111 | + } |
|
112 | + throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
113 | + } |
|
114 | + // is $middleware_app_class a valid FQCN (or class is already loaded) ? |
|
115 | + if(! class_exists($middleware_app_class)) { |
|
116 | + throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
|
117 | + } |
|
118 | + return $middleware_app; |
|
119 | + } |
|
120 | 120 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $middleware_app_args = array($application, $this->loader) + $middleware_app_args; |
70 | 70 | $application = $this->loader->getShared($middleware_app_class, $middleware_app_args); |
71 | 71 | } catch (InvalidRequestStackMiddlewareException $exception) { |
72 | - if(WP_DEBUG) { |
|
72 | + if (WP_DEBUG) { |
|
73 | 73 | new ExceptionStackTraceDisplay($exception); |
74 | 74 | continue; |
75 | 75 | } |
@@ -93,18 +93,18 @@ discard block |
||
93 | 93 | { |
94 | 94 | $middleware_app_class = reset($middleware_app); |
95 | 95 | // is array empty ? |
96 | - if($middleware_app_class === false) { |
|
96 | + if ($middleware_app_class === false) { |
|
97 | 97 | throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
98 | 98 | } |
99 | 99 | // are the class and arguments in the wrong order ? |
100 | - if(is_array($middleware_app_class)) { |
|
100 | + if (is_array($middleware_app_class)) { |
|
101 | 101 | if ($recurse === true) { |
102 | 102 | return $this->validateMiddlewareAppDetails(array_reverse($middleware_app)); |
103 | 103 | } |
104 | 104 | throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
105 | 105 | } |
106 | 106 | // is filter callback working like legacy middleware and sending a numerically indexed array ? |
107 | - if(is_int($middleware_app_class)) { |
|
107 | + if (is_int($middleware_app_class)) { |
|
108 | 108 | if ($recurse === true) { |
109 | 109 | $middleware_app = array_reverse($middleware_app); |
110 | 110 | return $this->validateMiddlewareAppDetails(array(reset($middleware_app), array())); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
113 | 113 | } |
114 | 114 | // is $middleware_app_class a valid FQCN (or class is already loaded) ? |
115 | - if(! class_exists($middleware_app_class)) { |
|
115 | + if ( ! class_exists($middleware_app_class)) { |
|
116 | 116 | throw new InvalidRequestStackMiddlewareException($middleware_app_class); |
117 | 117 | } |
118 | 118 | return $middleware_app; |
@@ -16,49 +16,49 @@ |
||
16 | 16 | interface DomainInterface extends InterminableInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return string |
|
21 | - * @throws DomainException |
|
22 | - */ |
|
23 | - public function pluginFile(); |
|
19 | + /** |
|
20 | + * @return string |
|
21 | + * @throws DomainException |
|
22 | + */ |
|
23 | + public function pluginFile(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - * @throws DomainException |
|
29 | - */ |
|
30 | - public function pluginBasename(); |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + * @throws DomainException |
|
29 | + */ |
|
30 | + public function pluginBasename(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function pluginPath(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function pluginPath(); |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - */ |
|
43 | - public function pluginUrl(); |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + */ |
|
43 | + public function pluginUrl(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @throws DomainException |
|
49 | - */ |
|
50 | - public function version(); |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @throws DomainException |
|
49 | + */ |
|
50 | + public function version(); |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function distributionAssetsPath(); |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function distributionAssetsPath(); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function distributionAssetsUrl(); |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function distributionAssetsUrl(); |
|
63 | 63 | |
64 | 64 | } |
@@ -24,459 +24,459 @@ |
||
24 | 24 | class Registry |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var EE_Template_Config $template_config |
|
29 | - */ |
|
30 | - protected $template_config; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var EE_Currency_Config $currency_config |
|
34 | - */ |
|
35 | - protected $currency_config; |
|
36 | - |
|
37 | - /** |
|
38 | - * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
39 | - * |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - protected $jsdata = array(); |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
47 | - * page source. |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - protected $script_handles_with_data = array(); |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @var DomainInterface |
|
55 | - */ |
|
56 | - protected $domain; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Registry constructor. |
|
61 | - * Hooking into WP actions for script registry. |
|
62 | - * |
|
63 | - * @param EE_Template_Config $template_config |
|
64 | - * @param EE_Currency_Config $currency_config |
|
65 | - * @param DomainInterface $domain |
|
66 | - */ |
|
67 | - public function __construct( |
|
68 | - EE_Template_Config $template_config, |
|
69 | - EE_Currency_Config $currency_config, |
|
70 | - DomainInterface $domain |
|
71 | - ) { |
|
72 | - $this->template_config = $template_config; |
|
73 | - $this->currency_config = $currency_config; |
|
74 | - $this->domain = $domain; |
|
75 | - add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
76 | - add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
77 | - add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
78 | - add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
79 | - add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
80 | - add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Callback for the WP script actions. |
|
87 | - * Used to register globally accessible core scripts. |
|
88 | - * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
89 | - */ |
|
90 | - public function scripts() |
|
91 | - { |
|
92 | - global $wp_version; |
|
93 | - wp_register_script( |
|
94 | - 'eejs-core', |
|
95 | - EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
96 | - array(), |
|
97 | - EVENT_ESPRESSO_VERSION, |
|
98 | - true |
|
99 | - ); |
|
100 | - //only run this if WordPress 4.4.0 > is in use. |
|
101 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
102 | - //js.api |
|
103 | - wp_register_script( |
|
104 | - 'eejs-api', |
|
105 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
106 | - array('underscore', 'eejs-core'), |
|
107 | - EVENT_ESPRESSO_VERSION, |
|
108 | - true |
|
109 | - ); |
|
110 | - $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
111 | - $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
112 | - } |
|
113 | - if (! is_admin()) { |
|
114 | - $this->loadCoreCss(); |
|
115 | - } |
|
116 | - $this->loadCoreJs(); |
|
117 | - $this->loadJqueryValidate(); |
|
118 | - $this->loadAccountingJs(); |
|
119 | - $this->loadQtipJs(); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * Call back for the script print in frontend and backend. |
|
126 | - * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
127 | - * |
|
128 | - * @since 4.9.31.rc.015 |
|
129 | - */ |
|
130 | - public function enqueueData() |
|
131 | - { |
|
132 | - $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
133 | - wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
134 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
135 | - $this->localizeAccountingJs(); |
|
136 | - $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
137 | - $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * Used to add data to eejs.data object. |
|
144 | - * Note: Overriding existing data is not allowed. |
|
145 | - * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
146 | - * If the data you add is something like this: |
|
147 | - * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
148 | - * It will be exposed in the page source as: |
|
149 | - * eejs.data.my_plugin_data.foo == gar |
|
150 | - * |
|
151 | - * @param string $key Key used to access your data |
|
152 | - * @param string|array $value Value to attach to key |
|
153 | - * @throws InvalidArgumentException |
|
154 | - */ |
|
155 | - public function addData($key, $value) |
|
156 | - { |
|
157 | - if ($this->verifyDataNotExisting($key)) { |
|
158 | - $this->jsdata[$key] = $value; |
|
159 | - } |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
166 | - * elements in an array. |
|
167 | - * When you use this method, the value you include will be appended to the end of an array on $key. |
|
168 | - * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
169 | - * object like this, eejs.data.test = [ my_data, |
|
170 | - * ] |
|
171 | - * If there has already been a scalar value attached to the data object given key, then |
|
172 | - * this will throw an exception. |
|
173 | - * |
|
174 | - * @param string $key Key to attach data to. |
|
175 | - * @param string|array $value Value being registered. |
|
176 | - * @throws InvalidArgumentException |
|
177 | - */ |
|
178 | - public function pushData($key, $value) |
|
179 | - { |
|
180 | - if (isset($this->jsdata[$key]) |
|
181 | - && ! is_array($this->jsdata[$key]) |
|
182 | - ) { |
|
183 | - throw new invalidArgumentException( |
|
184 | - sprintf( |
|
185 | - __( |
|
186 | - 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
27 | + /** |
|
28 | + * @var EE_Template_Config $template_config |
|
29 | + */ |
|
30 | + protected $template_config; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var EE_Currency_Config $currency_config |
|
34 | + */ |
|
35 | + protected $currency_config; |
|
36 | + |
|
37 | + /** |
|
38 | + * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script. |
|
39 | + * |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + protected $jsdata = array(); |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * This keeps track of all scripts with registered data. It is used to prevent duplicate data objects setup in the |
|
47 | + * page source. |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + protected $script_handles_with_data = array(); |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @var DomainInterface |
|
55 | + */ |
|
56 | + protected $domain; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Registry constructor. |
|
61 | + * Hooking into WP actions for script registry. |
|
62 | + * |
|
63 | + * @param EE_Template_Config $template_config |
|
64 | + * @param EE_Currency_Config $currency_config |
|
65 | + * @param DomainInterface $domain |
|
66 | + */ |
|
67 | + public function __construct( |
|
68 | + EE_Template_Config $template_config, |
|
69 | + EE_Currency_Config $currency_config, |
|
70 | + DomainInterface $domain |
|
71 | + ) { |
|
72 | + $this->template_config = $template_config; |
|
73 | + $this->currency_config = $currency_config; |
|
74 | + $this->domain = $domain; |
|
75 | + add_action('wp_enqueue_scripts', array($this, 'scripts'), 1); |
|
76 | + add_action('admin_enqueue_scripts', array($this, 'scripts'), 1); |
|
77 | + add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
78 | + add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2); |
|
79 | + add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
80 | + add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Callback for the WP script actions. |
|
87 | + * Used to register globally accessible core scripts. |
|
88 | + * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency. |
|
89 | + */ |
|
90 | + public function scripts() |
|
91 | + { |
|
92 | + global $wp_version; |
|
93 | + wp_register_script( |
|
94 | + 'eejs-core', |
|
95 | + EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js', |
|
96 | + array(), |
|
97 | + EVENT_ESPRESSO_VERSION, |
|
98 | + true |
|
99 | + ); |
|
100 | + //only run this if WordPress 4.4.0 > is in use. |
|
101 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
102 | + //js.api |
|
103 | + wp_register_script( |
|
104 | + 'eejs-api', |
|
105 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
106 | + array('underscore', 'eejs-core'), |
|
107 | + EVENT_ESPRESSO_VERSION, |
|
108 | + true |
|
109 | + ); |
|
110 | + $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest'); |
|
111 | + $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/')); |
|
112 | + } |
|
113 | + if (! is_admin()) { |
|
114 | + $this->loadCoreCss(); |
|
115 | + } |
|
116 | + $this->loadCoreJs(); |
|
117 | + $this->loadJqueryValidate(); |
|
118 | + $this->loadAccountingJs(); |
|
119 | + $this->loadQtipJs(); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * Call back for the script print in frontend and backend. |
|
126 | + * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point. |
|
127 | + * |
|
128 | + * @since 4.9.31.rc.015 |
|
129 | + */ |
|
130 | + public function enqueueData() |
|
131 | + { |
|
132 | + $this->removeAlreadyRegisteredDataForScriptHandles(); |
|
133 | + wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata)); |
|
134 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
135 | + $this->localizeAccountingJs(); |
|
136 | + $this->addRegisteredScriptHandlesWithData('eejs-core'); |
|
137 | + $this->addRegisteredScriptHandlesWithData('espresso_core'); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * Used to add data to eejs.data object. |
|
144 | + * Note: Overriding existing data is not allowed. |
|
145 | + * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript. |
|
146 | + * If the data you add is something like this: |
|
147 | + * $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) ); |
|
148 | + * It will be exposed in the page source as: |
|
149 | + * eejs.data.my_plugin_data.foo == gar |
|
150 | + * |
|
151 | + * @param string $key Key used to access your data |
|
152 | + * @param string|array $value Value to attach to key |
|
153 | + * @throws InvalidArgumentException |
|
154 | + */ |
|
155 | + public function addData($key, $value) |
|
156 | + { |
|
157 | + if ($this->verifyDataNotExisting($key)) { |
|
158 | + $this->jsdata[$key] = $value; |
|
159 | + } |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Similar to addData except this allows for users to push values to an existing key where the values on key are |
|
166 | + * elements in an array. |
|
167 | + * When you use this method, the value you include will be appended to the end of an array on $key. |
|
168 | + * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript |
|
169 | + * object like this, eejs.data.test = [ my_data, |
|
170 | + * ] |
|
171 | + * If there has already been a scalar value attached to the data object given key, then |
|
172 | + * this will throw an exception. |
|
173 | + * |
|
174 | + * @param string $key Key to attach data to. |
|
175 | + * @param string|array $value Value being registered. |
|
176 | + * @throws InvalidArgumentException |
|
177 | + */ |
|
178 | + public function pushData($key, $value) |
|
179 | + { |
|
180 | + if (isset($this->jsdata[$key]) |
|
181 | + && ! is_array($this->jsdata[$key]) |
|
182 | + ) { |
|
183 | + throw new invalidArgumentException( |
|
184 | + sprintf( |
|
185 | + __( |
|
186 | + 'The value for %1$s is already set and it is not an array. The %2$s method can only be used to |
|
187 | 187 | push values to this data element when it is an array.', |
188 | - 'event_espresso' |
|
189 | - ), |
|
190 | - $key, |
|
191 | - __METHOD__ |
|
192 | - ) |
|
193 | - ); |
|
194 | - } |
|
195 | - $this->jsdata[$key][] = $value; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * Used to set content used by javascript for a template. |
|
202 | - * Note: Overrides of existing registered templates are not allowed. |
|
203 | - * |
|
204 | - * @param string $template_reference |
|
205 | - * @param string $template_content |
|
206 | - * @throws InvalidArgumentException |
|
207 | - */ |
|
208 | - public function addTemplate($template_reference, $template_content) |
|
209 | - { |
|
210 | - if (! isset($this->jsdata['templates'])) { |
|
211 | - $this->jsdata['templates'] = array(); |
|
212 | - } |
|
213 | - //no overrides allowed. |
|
214 | - if (isset($this->jsdata['templates'][$template_reference])) { |
|
215 | - throw new invalidArgumentException( |
|
216 | - sprintf( |
|
217 | - __( |
|
218 | - 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
219 | - 'event_espresso' |
|
220 | - ), |
|
221 | - $template_reference |
|
222 | - ) |
|
223 | - ); |
|
224 | - } |
|
225 | - $this->jsdata['templates'][$template_reference] = $template_content; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * Retrieve the template content already registered for the given reference. |
|
232 | - * |
|
233 | - * @param string $template_reference |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - public function getTemplate($template_reference) |
|
237 | - { |
|
238 | - return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
239 | - ? $this->jsdata['templates'][$template_reference] |
|
240 | - : ''; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * Retrieve registered data. |
|
247 | - * |
|
248 | - * @param string $key Name of key to attach data to. |
|
249 | - * @return mixed If there is no for the given key, then false is returned. |
|
250 | - */ |
|
251 | - public function getData($key) |
|
252 | - { |
|
253 | - return isset($this->jsdata[$key]) |
|
254 | - ? $this->jsdata[$key] |
|
255 | - : false; |
|
256 | - } |
|
257 | - |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * Verifies whether the given data exists already on the jsdata array. |
|
262 | - * Overriding data is not allowed. |
|
263 | - * |
|
264 | - * @param string $key Index for data. |
|
265 | - * @return bool If valid then return true. |
|
266 | - * @throws InvalidArgumentException if data already exists. |
|
267 | - */ |
|
268 | - protected function verifyDataNotExisting($key) |
|
269 | - { |
|
270 | - if (isset($this->jsdata[$key])) { |
|
271 | - if (is_array($this->jsdata[$key])) { |
|
272 | - throw new InvalidArgumentException( |
|
273 | - sprintf( |
|
274 | - __( |
|
275 | - 'The value for %1$s already exists in the Registry::eejs object. |
|
188 | + 'event_espresso' |
|
189 | + ), |
|
190 | + $key, |
|
191 | + __METHOD__ |
|
192 | + ) |
|
193 | + ); |
|
194 | + } |
|
195 | + $this->jsdata[$key][] = $value; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * Used to set content used by javascript for a template. |
|
202 | + * Note: Overrides of existing registered templates are not allowed. |
|
203 | + * |
|
204 | + * @param string $template_reference |
|
205 | + * @param string $template_content |
|
206 | + * @throws InvalidArgumentException |
|
207 | + */ |
|
208 | + public function addTemplate($template_reference, $template_content) |
|
209 | + { |
|
210 | + if (! isset($this->jsdata['templates'])) { |
|
211 | + $this->jsdata['templates'] = array(); |
|
212 | + } |
|
213 | + //no overrides allowed. |
|
214 | + if (isset($this->jsdata['templates'][$template_reference])) { |
|
215 | + throw new invalidArgumentException( |
|
216 | + sprintf( |
|
217 | + __( |
|
218 | + 'The %1$s key already exists for the templates array in the js data array. No overrides are allowed.', |
|
219 | + 'event_espresso' |
|
220 | + ), |
|
221 | + $template_reference |
|
222 | + ) |
|
223 | + ); |
|
224 | + } |
|
225 | + $this->jsdata['templates'][$template_reference] = $template_content; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * Retrieve the template content already registered for the given reference. |
|
232 | + * |
|
233 | + * @param string $template_reference |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + public function getTemplate($template_reference) |
|
237 | + { |
|
238 | + return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference]) |
|
239 | + ? $this->jsdata['templates'][$template_reference] |
|
240 | + : ''; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * Retrieve registered data. |
|
247 | + * |
|
248 | + * @param string $key Name of key to attach data to. |
|
249 | + * @return mixed If there is no for the given key, then false is returned. |
|
250 | + */ |
|
251 | + public function getData($key) |
|
252 | + { |
|
253 | + return isset($this->jsdata[$key]) |
|
254 | + ? $this->jsdata[$key] |
|
255 | + : false; |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * Verifies whether the given data exists already on the jsdata array. |
|
262 | + * Overriding data is not allowed. |
|
263 | + * |
|
264 | + * @param string $key Index for data. |
|
265 | + * @return bool If valid then return true. |
|
266 | + * @throws InvalidArgumentException if data already exists. |
|
267 | + */ |
|
268 | + protected function verifyDataNotExisting($key) |
|
269 | + { |
|
270 | + if (isset($this->jsdata[$key])) { |
|
271 | + if (is_array($this->jsdata[$key])) { |
|
272 | + throw new InvalidArgumentException( |
|
273 | + sprintf( |
|
274 | + __( |
|
275 | + 'The value for %1$s already exists in the Registry::eejs object. |
|
276 | 276 | Overrides are not allowed. Since the value of this data is an array, you may want to use the |
277 | 277 | %2$s method to push your value to the array.', |
278 | - 'event_espresso' |
|
279 | - ), |
|
280 | - $key, |
|
281 | - 'pushData()' |
|
282 | - ) |
|
283 | - ); |
|
284 | - } |
|
285 | - throw new InvalidArgumentException( |
|
286 | - sprintf( |
|
287 | - __( |
|
288 | - 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
278 | + 'event_espresso' |
|
279 | + ), |
|
280 | + $key, |
|
281 | + 'pushData()' |
|
282 | + ) |
|
283 | + ); |
|
284 | + } |
|
285 | + throw new InvalidArgumentException( |
|
286 | + sprintf( |
|
287 | + __( |
|
288 | + 'The value for %1$s already exists in the Registry::eejs object. Overrides are not |
|
289 | 289 | allowed. Consider attaching your value to a different key', |
290 | - 'event_espresso' |
|
291 | - ), |
|
292 | - $key |
|
293 | - ) |
|
294 | - ); |
|
295 | - } |
|
296 | - return true; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * registers core default stylesheets |
|
303 | - */ |
|
304 | - private function loadCoreCss() |
|
305 | - { |
|
306 | - if ($this->template_config->enable_default_style) { |
|
307 | - $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
308 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
309 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
310 | - wp_register_style( |
|
311 | - 'espresso_default', |
|
312 | - $default_stylesheet_path, |
|
313 | - array('dashicons'), |
|
314 | - EVENT_ESPRESSO_VERSION |
|
315 | - ); |
|
316 | - //Load custom style sheet if available |
|
317 | - if ($this->template_config->custom_style_sheet !== null) { |
|
318 | - wp_register_style( |
|
319 | - 'espresso_custom_css', |
|
320 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
321 | - array('espresso_default'), |
|
322 | - EVENT_ESPRESSO_VERSION |
|
323 | - ); |
|
324 | - } |
|
325 | - } |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * registers core default javascript |
|
332 | - */ |
|
333 | - private function loadCoreJs() |
|
334 | - { |
|
335 | - // load core js |
|
336 | - wp_register_script( |
|
337 | - 'espresso_core', |
|
338 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
339 | - array('jquery'), |
|
340 | - EVENT_ESPRESSO_VERSION, |
|
341 | - true |
|
342 | - ); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * registers jQuery Validate for form validation |
|
349 | - */ |
|
350 | - private function loadJqueryValidate() |
|
351 | - { |
|
352 | - // register jQuery Validate and additional methods |
|
353 | - wp_register_script( |
|
354 | - 'jquery-validate', |
|
355 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
356 | - array('jquery'), |
|
357 | - '1.15.0', |
|
358 | - true |
|
359 | - ); |
|
360 | - wp_register_script( |
|
361 | - 'jquery-validate-extra-methods', |
|
362 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
363 | - array('jquery', 'jquery-validate'), |
|
364 | - '1.15.0', |
|
365 | - true |
|
366 | - ); |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * registers accounting.js for performing client-side calculations |
|
373 | - */ |
|
374 | - private function loadAccountingJs() |
|
375 | - { |
|
376 | - //accounting.js library |
|
377 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
378 | - wp_register_script( |
|
379 | - 'ee-accounting-core', |
|
380 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
381 | - array('underscore'), |
|
382 | - '0.3.2', |
|
383 | - true |
|
384 | - ); |
|
385 | - wp_register_script( |
|
386 | - 'ee-accounting', |
|
387 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
388 | - array('ee-accounting-core'), |
|
389 | - EVENT_ESPRESSO_VERSION, |
|
390 | - true |
|
391 | - ); |
|
392 | - } |
|
393 | - |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * registers accounting.js for performing client-side calculations |
|
398 | - */ |
|
399 | - private function localizeAccountingJs() |
|
400 | - { |
|
401 | - wp_localize_script( |
|
402 | - 'ee-accounting', |
|
403 | - 'EE_ACCOUNTING_CFG', |
|
404 | - array( |
|
405 | - 'currency' => array( |
|
406 | - 'symbol' => $this->currency_config->sign, |
|
407 | - 'format' => array( |
|
408 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
409 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
410 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
411 | - ), |
|
412 | - 'decimal' => $this->currency_config->dec_mrk, |
|
413 | - 'thousand' => $this->currency_config->thsnds, |
|
414 | - 'precision' => $this->currency_config->dec_plc, |
|
415 | - ), |
|
416 | - 'number' => array( |
|
417 | - 'precision' => $this->currency_config->dec_plc, |
|
418 | - 'thousand' => $this->currency_config->thsnds, |
|
419 | - 'decimal' => $this->currency_config->dec_mrk, |
|
420 | - ), |
|
421 | - ) |
|
422 | - ); |
|
423 | - $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * registers assets for cleaning your ears |
|
430 | - */ |
|
431 | - private function loadQtipJs() |
|
432 | - { |
|
433 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
434 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
435 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
436 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
437 | - } |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * This is used to set registered script handles that have data. |
|
443 | - * @param string $script_handle |
|
444 | - */ |
|
445 | - private function addRegisteredScriptHandlesWithData($script_handle) |
|
446 | - { |
|
447 | - $this->script_handles_with_data[$script_handle] = $script_handle; |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
|
453 | - * Dependency stored in WP_Scripts if its set. |
|
454 | - */ |
|
455 | - private function removeAlreadyRegisteredDataForScriptHandles() |
|
456 | - { |
|
457 | - if (empty($this->script_handles_with_data)) { |
|
458 | - return; |
|
459 | - } |
|
460 | - foreach ($this->script_handles_with_data as $script_handle) { |
|
461 | - $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
462 | - } |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - /** |
|
467 | - * Removes any data dependency registered in WP_Scripts if its set. |
|
468 | - * @param string $script_handle |
|
469 | - */ |
|
470 | - private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
471 | - { |
|
472 | - if (isset($this->script_handles_with_data[$script_handle])) { |
|
473 | - global $wp_scripts; |
|
474 | - if ($wp_scripts->get_data($script_handle, 'data')) { |
|
475 | - unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
476 | - unset($this->script_handles_with_data[$script_handle]); |
|
477 | - } |
|
478 | - } |
|
479 | - } |
|
290 | + 'event_espresso' |
|
291 | + ), |
|
292 | + $key |
|
293 | + ) |
|
294 | + ); |
|
295 | + } |
|
296 | + return true; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * registers core default stylesheets |
|
303 | + */ |
|
304 | + private function loadCoreCss() |
|
305 | + { |
|
306 | + if ($this->template_config->enable_default_style) { |
|
307 | + $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
308 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
309 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css'; |
|
310 | + wp_register_style( |
|
311 | + 'espresso_default', |
|
312 | + $default_stylesheet_path, |
|
313 | + array('dashicons'), |
|
314 | + EVENT_ESPRESSO_VERSION |
|
315 | + ); |
|
316 | + //Load custom style sheet if available |
|
317 | + if ($this->template_config->custom_style_sheet !== null) { |
|
318 | + wp_register_style( |
|
319 | + 'espresso_custom_css', |
|
320 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
321 | + array('espresso_default'), |
|
322 | + EVENT_ESPRESSO_VERSION |
|
323 | + ); |
|
324 | + } |
|
325 | + } |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * registers core default javascript |
|
332 | + */ |
|
333 | + private function loadCoreJs() |
|
334 | + { |
|
335 | + // load core js |
|
336 | + wp_register_script( |
|
337 | + 'espresso_core', |
|
338 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
339 | + array('jquery'), |
|
340 | + EVENT_ESPRESSO_VERSION, |
|
341 | + true |
|
342 | + ); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * registers jQuery Validate for form validation |
|
349 | + */ |
|
350 | + private function loadJqueryValidate() |
|
351 | + { |
|
352 | + // register jQuery Validate and additional methods |
|
353 | + wp_register_script( |
|
354 | + 'jquery-validate', |
|
355 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
356 | + array('jquery'), |
|
357 | + '1.15.0', |
|
358 | + true |
|
359 | + ); |
|
360 | + wp_register_script( |
|
361 | + 'jquery-validate-extra-methods', |
|
362 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
363 | + array('jquery', 'jquery-validate'), |
|
364 | + '1.15.0', |
|
365 | + true |
|
366 | + ); |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * registers accounting.js for performing client-side calculations |
|
373 | + */ |
|
374 | + private function loadAccountingJs() |
|
375 | + { |
|
376 | + //accounting.js library |
|
377 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
378 | + wp_register_script( |
|
379 | + 'ee-accounting-core', |
|
380 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
381 | + array('underscore'), |
|
382 | + '0.3.2', |
|
383 | + true |
|
384 | + ); |
|
385 | + wp_register_script( |
|
386 | + 'ee-accounting', |
|
387 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
388 | + array('ee-accounting-core'), |
|
389 | + EVENT_ESPRESSO_VERSION, |
|
390 | + true |
|
391 | + ); |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * registers accounting.js for performing client-side calculations |
|
398 | + */ |
|
399 | + private function localizeAccountingJs() |
|
400 | + { |
|
401 | + wp_localize_script( |
|
402 | + 'ee-accounting', |
|
403 | + 'EE_ACCOUNTING_CFG', |
|
404 | + array( |
|
405 | + 'currency' => array( |
|
406 | + 'symbol' => $this->currency_config->sign, |
|
407 | + 'format' => array( |
|
408 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
409 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
410 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
411 | + ), |
|
412 | + 'decimal' => $this->currency_config->dec_mrk, |
|
413 | + 'thousand' => $this->currency_config->thsnds, |
|
414 | + 'precision' => $this->currency_config->dec_plc, |
|
415 | + ), |
|
416 | + 'number' => array( |
|
417 | + 'precision' => $this->currency_config->dec_plc, |
|
418 | + 'thousand' => $this->currency_config->thsnds, |
|
419 | + 'decimal' => $this->currency_config->dec_mrk, |
|
420 | + ), |
|
421 | + ) |
|
422 | + ); |
|
423 | + $this->addRegisteredScriptHandlesWithData('ee-accounting'); |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * registers assets for cleaning your ears |
|
430 | + */ |
|
431 | + private function loadQtipJs() |
|
432 | + { |
|
433 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
434 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
435 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
436 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
437 | + } |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * This is used to set registered script handles that have data. |
|
443 | + * @param string $script_handle |
|
444 | + */ |
|
445 | + private function addRegisteredScriptHandlesWithData($script_handle) |
|
446 | + { |
|
447 | + $this->script_handles_with_data[$script_handle] = $script_handle; |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the |
|
453 | + * Dependency stored in WP_Scripts if its set. |
|
454 | + */ |
|
455 | + private function removeAlreadyRegisteredDataForScriptHandles() |
|
456 | + { |
|
457 | + if (empty($this->script_handles_with_data)) { |
|
458 | + return; |
|
459 | + } |
|
460 | + foreach ($this->script_handles_with_data as $script_handle) { |
|
461 | + $this->removeAlreadyRegisteredDataForScriptHandle($script_handle); |
|
462 | + } |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + /** |
|
467 | + * Removes any data dependency registered in WP_Scripts if its set. |
|
468 | + * @param string $script_handle |
|
469 | + */ |
|
470 | + private function removeAlreadyRegisteredDataForScriptHandle($script_handle) |
|
471 | + { |
|
472 | + if (isset($this->script_handles_with_data[$script_handle])) { |
|
473 | + global $wp_scripts; |
|
474 | + if ($wp_scripts->get_data($script_handle, 'data')) { |
|
475 | + unset($wp_scripts->registered[$script_handle]->extra['data']); |
|
476 | + unset($this->script_handles_with_data[$script_handle]); |
|
477 | + } |
|
478 | + } |
|
479 | + } |
|
480 | 480 | |
481 | 481 | |
482 | 482 | } |
@@ -52,234 +52,234 @@ |
||
52 | 52 | class BootstrapCore |
53 | 53 | { |
54 | 54 | |
55 | - /** |
|
56 | - * @type LoaderInterface $loader |
|
57 | - */ |
|
58 | - private $loader; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var RequestInterface $request |
|
62 | - */ |
|
63 | - protected $request; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var ResponseInterface $response |
|
67 | - */ |
|
68 | - protected $response; |
|
69 | - |
|
70 | - /** |
|
71 | - * @var RequestStackBuilder $request_stack_builder |
|
72 | - */ |
|
73 | - protected $request_stack_builder; |
|
74 | - |
|
75 | - /** |
|
76 | - * @var RequestStack $request_stack |
|
77 | - */ |
|
78 | - protected $request_stack; |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * BootstrapCore constructor. |
|
83 | - */ |
|
84 | - public function __construct() |
|
85 | - { |
|
86 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
87 | - add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @throws InvalidRequestStackMiddlewareException |
|
93 | - * @throws InvalidClassException |
|
94 | - * @throws DomainException |
|
95 | - * @throws EE_Error |
|
96 | - * @throws InvalidArgumentException |
|
97 | - * @throws InvalidDataTypeException |
|
98 | - * @throws InvalidInterfaceException |
|
99 | - * @throws ReflectionException |
|
100 | - */ |
|
101 | - public function initialize() |
|
102 | - { |
|
103 | - $this->bootstrapDependencyInjectionContainer(); |
|
104 | - $this->bootstrapDomain(); |
|
105 | - $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
106 | - add_action( |
|
107 | - 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
108 | - array($bootstrap_request, 'setupLegacyRequest') |
|
109 | - ); |
|
110 | - $this->runRequestStack(); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @throws ReflectionException |
|
116 | - * @throws EE_Error |
|
117 | - * @throws InvalidArgumentException |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - */ |
|
121 | - private function bootstrapDependencyInjectionContainer() |
|
122 | - { |
|
123 | - $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
124 | - $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
125 | - $bootstrap_di->buildLoader(); |
|
126 | - $registry = $bootstrap_di->getRegistry(); |
|
127 | - $dependency_map = $bootstrap_di->getDependencyMap(); |
|
128 | - $dependency_map->initialize(); |
|
129 | - $registry->initialize(); |
|
130 | - $this->loader = $bootstrap_di->getLoader(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * configures the Domain object for core |
|
136 | - * |
|
137 | - * @return void |
|
138 | - * @throws DomainException |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidClassException |
|
142 | - * @throws InvalidFilePathException |
|
143 | - * @throws InvalidInterfaceException |
|
144 | - */ |
|
145 | - private function bootstrapDomain() |
|
146 | - { |
|
147 | - DomainFactory::getShared( |
|
148 | - new FullyQualifiedName( |
|
149 | - 'EventEspresso\core\domain\Domain' |
|
150 | - ), |
|
151 | - array( |
|
152 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
153 | - Version::fromString(espresso_version()) |
|
154 | - ) |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * sets up the request and response objects |
|
161 | - * |
|
162 | - * @return BootstrapRequestResponseObjects |
|
163 | - * @throws InvalidArgumentException |
|
164 | - */ |
|
165 | - private function bootstrapRequestResponseObjects() |
|
166 | - { |
|
167 | - /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
168 | - $bootstrap_request = $this->loader->getShared( |
|
169 | - 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
170 | - array($this->loader) |
|
171 | - ); |
|
172 | - $bootstrap_request->buildRequestResponse(); |
|
173 | - $bootstrap_request->shareRequestResponse(); |
|
174 | - $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
175 | - $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
176 | - return $bootstrap_request; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * run_request_stack |
|
182 | - * construct request stack and run middleware apps |
|
183 | - * |
|
184 | - * @throws InvalidRequestStackMiddlewareException |
|
185 | - * @throws InvalidInterfaceException |
|
186 | - * @throws InvalidDataTypeException |
|
187 | - * @throws EE_Error |
|
188 | - */ |
|
189 | - public function runRequestStack() |
|
190 | - { |
|
191 | - $this->loadAutoloader(); |
|
192 | - $this->setAutoloadersForRequiredFiles(); |
|
193 | - $this->request_stack_builder = $this->buildRequestStack(); |
|
194 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
195 | - new RequestStackCoreApp() |
|
196 | - ); |
|
197 | - $this->request_stack->handleRequest($this->request, $this->response); |
|
198 | - $this->request_stack->handleResponse(); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * load_autoloader |
|
204 | - * |
|
205 | - * @throws EE_Error |
|
206 | - */ |
|
207 | - protected function loadAutoloader() |
|
208 | - { |
|
209 | - // load interfaces |
|
210 | - espresso_load_required( |
|
211 | - 'EEH_Autoloader', |
|
212 | - EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
213 | - ); |
|
214 | - EEH_Autoloader::instance(); |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * load_required_files |
|
221 | - * |
|
222 | - * @throws EE_Error |
|
223 | - */ |
|
224 | - protected function setAutoloadersForRequiredFiles() |
|
225 | - { |
|
226 | - // load interfaces |
|
227 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
228 | - // load helpers |
|
229 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
230 | - // load request stack |
|
231 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
232 | - // load middleware |
|
233 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * build_request_stack |
|
240 | - * |
|
241 | - * @return RequestStackBuilder |
|
242 | - */ |
|
243 | - public function buildRequestStack() |
|
244 | - { |
|
245 | - $request_stack_builder = new RequestStackBuilder($this->loader); |
|
246 | - /** |
|
247 | - * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
248 | - * so items at the beginning of the final middleware stack will run last. |
|
249 | - * First parameter is the middleware classname, second is an array of arguments |
|
250 | - */ |
|
251 | - $stack_apps = apply_filters( |
|
252 | - 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
253 | - array( |
|
254 | - // first in last out |
|
255 | - 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
256 | - 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
257 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
258 | - 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
259 | - // last in first out |
|
260 | - 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
261 | - ) |
|
262 | - ); |
|
263 | - // legacy filter for backwards compatibility |
|
264 | - $stack_apps = apply_filters( |
|
265 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
266 | - $stack_apps |
|
267 | - ); |
|
268 | - // load middleware onto stack : FILO (First In Last Out) |
|
269 | - // items at the beginning of the $stack_apps array will run last |
|
270 | - foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
271 | - $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
272 | - } |
|
273 | - // finally, we'll add this on its own because we need it to always be part of the stack |
|
274 | - // and we also need it to always run first because the rest of the system relies on it |
|
275 | - $request_stack_builder->push( |
|
276 | - array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
277 | - ); |
|
278 | - return apply_filters( |
|
279 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
280 | - $request_stack_builder |
|
281 | - ); |
|
282 | - } |
|
55 | + /** |
|
56 | + * @type LoaderInterface $loader |
|
57 | + */ |
|
58 | + private $loader; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var RequestInterface $request |
|
62 | + */ |
|
63 | + protected $request; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var ResponseInterface $response |
|
67 | + */ |
|
68 | + protected $response; |
|
69 | + |
|
70 | + /** |
|
71 | + * @var RequestStackBuilder $request_stack_builder |
|
72 | + */ |
|
73 | + protected $request_stack_builder; |
|
74 | + |
|
75 | + /** |
|
76 | + * @var RequestStack $request_stack |
|
77 | + */ |
|
78 | + protected $request_stack; |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * BootstrapCore constructor. |
|
83 | + */ |
|
84 | + public function __construct() |
|
85 | + { |
|
86 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
87 | + add_action('plugins_loaded', array($this, 'initialize'), 0); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @throws InvalidRequestStackMiddlewareException |
|
93 | + * @throws InvalidClassException |
|
94 | + * @throws DomainException |
|
95 | + * @throws EE_Error |
|
96 | + * @throws InvalidArgumentException |
|
97 | + * @throws InvalidDataTypeException |
|
98 | + * @throws InvalidInterfaceException |
|
99 | + * @throws ReflectionException |
|
100 | + */ |
|
101 | + public function initialize() |
|
102 | + { |
|
103 | + $this->bootstrapDependencyInjectionContainer(); |
|
104 | + $this->bootstrapDomain(); |
|
105 | + $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
106 | + add_action( |
|
107 | + 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
108 | + array($bootstrap_request, 'setupLegacyRequest') |
|
109 | + ); |
|
110 | + $this->runRequestStack(); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @throws ReflectionException |
|
116 | + * @throws EE_Error |
|
117 | + * @throws InvalidArgumentException |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + */ |
|
121 | + private function bootstrapDependencyInjectionContainer() |
|
122 | + { |
|
123 | + $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
124 | + $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
125 | + $bootstrap_di->buildLoader(); |
|
126 | + $registry = $bootstrap_di->getRegistry(); |
|
127 | + $dependency_map = $bootstrap_di->getDependencyMap(); |
|
128 | + $dependency_map->initialize(); |
|
129 | + $registry->initialize(); |
|
130 | + $this->loader = $bootstrap_di->getLoader(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * configures the Domain object for core |
|
136 | + * |
|
137 | + * @return void |
|
138 | + * @throws DomainException |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidClassException |
|
142 | + * @throws InvalidFilePathException |
|
143 | + * @throws InvalidInterfaceException |
|
144 | + */ |
|
145 | + private function bootstrapDomain() |
|
146 | + { |
|
147 | + DomainFactory::getShared( |
|
148 | + new FullyQualifiedName( |
|
149 | + 'EventEspresso\core\domain\Domain' |
|
150 | + ), |
|
151 | + array( |
|
152 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
153 | + Version::fromString(espresso_version()) |
|
154 | + ) |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * sets up the request and response objects |
|
161 | + * |
|
162 | + * @return BootstrapRequestResponseObjects |
|
163 | + * @throws InvalidArgumentException |
|
164 | + */ |
|
165 | + private function bootstrapRequestResponseObjects() |
|
166 | + { |
|
167 | + /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
168 | + $bootstrap_request = $this->loader->getShared( |
|
169 | + 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
170 | + array($this->loader) |
|
171 | + ); |
|
172 | + $bootstrap_request->buildRequestResponse(); |
|
173 | + $bootstrap_request->shareRequestResponse(); |
|
174 | + $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
175 | + $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
176 | + return $bootstrap_request; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * run_request_stack |
|
182 | + * construct request stack and run middleware apps |
|
183 | + * |
|
184 | + * @throws InvalidRequestStackMiddlewareException |
|
185 | + * @throws InvalidInterfaceException |
|
186 | + * @throws InvalidDataTypeException |
|
187 | + * @throws EE_Error |
|
188 | + */ |
|
189 | + public function runRequestStack() |
|
190 | + { |
|
191 | + $this->loadAutoloader(); |
|
192 | + $this->setAutoloadersForRequiredFiles(); |
|
193 | + $this->request_stack_builder = $this->buildRequestStack(); |
|
194 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
195 | + new RequestStackCoreApp() |
|
196 | + ); |
|
197 | + $this->request_stack->handleRequest($this->request, $this->response); |
|
198 | + $this->request_stack->handleResponse(); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * load_autoloader |
|
204 | + * |
|
205 | + * @throws EE_Error |
|
206 | + */ |
|
207 | + protected function loadAutoloader() |
|
208 | + { |
|
209 | + // load interfaces |
|
210 | + espresso_load_required( |
|
211 | + 'EEH_Autoloader', |
|
212 | + EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
213 | + ); |
|
214 | + EEH_Autoloader::instance(); |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * load_required_files |
|
221 | + * |
|
222 | + * @throws EE_Error |
|
223 | + */ |
|
224 | + protected function setAutoloadersForRequiredFiles() |
|
225 | + { |
|
226 | + // load interfaces |
|
227 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
228 | + // load helpers |
|
229 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
230 | + // load request stack |
|
231 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
232 | + // load middleware |
|
233 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * build_request_stack |
|
240 | + * |
|
241 | + * @return RequestStackBuilder |
|
242 | + */ |
|
243 | + public function buildRequestStack() |
|
244 | + { |
|
245 | + $request_stack_builder = new RequestStackBuilder($this->loader); |
|
246 | + /** |
|
247 | + * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
248 | + * so items at the beginning of the final middleware stack will run last. |
|
249 | + * First parameter is the middleware classname, second is an array of arguments |
|
250 | + */ |
|
251 | + $stack_apps = apply_filters( |
|
252 | + 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
253 | + array( |
|
254 | + // first in last out |
|
255 | + 'EventEspresso\core\services\request\middleware\BotDetector' => array(), |
|
256 | + 'EventEspresso\core\services\request\middleware\DetectFileEditorRequest' => array(), |
|
257 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning' => array(), |
|
258 | + 'EventEspresso\core\services\request\middleware\RecommendedVersions' => array(), |
|
259 | + // last in first out |
|
260 | + 'EventEspresso\core\services\request\middleware\DetectLogin' => array(), |
|
261 | + ) |
|
262 | + ); |
|
263 | + // legacy filter for backwards compatibility |
|
264 | + $stack_apps = apply_filters( |
|
265 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
266 | + $stack_apps |
|
267 | + ); |
|
268 | + // load middleware onto stack : FILO (First In Last Out) |
|
269 | + // items at the beginning of the $stack_apps array will run last |
|
270 | + foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
271 | + $request_stack_builder->push(array($stack_app, $stack_app_args)); |
|
272 | + } |
|
273 | + // finally, we'll add this on its own because we need it to always be part of the stack |
|
274 | + // and we also need it to always run first because the rest of the system relies on it |
|
275 | + $request_stack_builder->push( |
|
276 | + array('EventEspresso\core\services\request\middleware\SetRequestTypeContextChecker', array()) |
|
277 | + ); |
|
278 | + return apply_filters( |
|
279 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
280 | + $request_stack_builder |
|
281 | + ); |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | } |