@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | *@param array $settings_array |
98 | 98 | */ |
99 | - public function set_settings( $settings_array ) { |
|
99 | + public function set_settings($settings_array) { |
|
100 | 100 | parent::set_settings($settings_array); |
101 | 101 | // Redirect URL. |
102 | 102 | $this->_base_gateway_url = $this->_debug_mode |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | * @return \EE_Payment|\EEI_Payment |
116 | 116 | * @throws \EE_Error |
117 | 117 | */ |
118 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
119 | - if ( ! $payment instanceof EEI_Payment ) { |
|
120 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
121 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
118 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
119 | + if ( ! $payment instanceof EEI_Payment) { |
|
120 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
121 | + $payment->set_status($this->_pay_model->failed_status()); |
|
122 | 122 | return $payment; |
123 | 123 | } |
124 | 124 | $transaction = $payment->transaction(); |
125 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
126 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
127 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
125 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
126 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
127 | + $payment->set_status($this->_pay_model->failed_status()); |
|
128 | 128 | return $payment; |
129 | 129 | } |
130 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
130 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
131 | 131 | $primary_registration = $transaction->primary_registration(); |
132 | 132 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
133 | 133 | $locale = explode('-', get_bloginfo('language')); |
@@ -141,37 +141,37 @@ discard block |
||
141 | 141 | 'RETURNURL' => $return_url, |
142 | 142 | 'CANCELURL' => $cancel_url, |
143 | 143 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
144 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
144 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
145 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
146 | 146 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
147 | 147 | ); |
148 | 148 | |
149 | 149 | // Show itemized list. |
150 | - if ( $this->_money->compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
150 | + if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
151 | 151 | $item_num = 0; |
152 | 152 | $itemized_sum = 0; |
153 | 153 | $total_line_items = $transaction->total_line_item(); |
154 | 154 | // Go through each item in the list. |
155 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
156 | - if ( $line_item instanceof EE_Line_Item ) { |
|
155 | + foreach ($total_line_items->get_items() as $line_item) { |
|
156 | + if ($line_item instanceof EE_Line_Item) { |
|
157 | 157 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
158 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
158 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
159 | 159 | continue; |
160 | 160 | } |
161 | 161 | |
162 | 162 | $unit_price = $line_item->unit_price(); |
163 | 163 | $line_item_quantity = $line_item->quantity(); |
164 | 164 | // This is a discount. |
165 | - if ( $line_item->is_percent() ) { |
|
165 | + if ($line_item->is_percent()) { |
|
166 | 166 | $unit_price = $line_item->total(); |
167 | 167 | $line_item_quantity = 1; |
168 | 168 | } |
169 | 169 | // Item Name. |
170 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name( $line_item, $payment), 0, 127); |
|
170 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr($this->_format_line_item_name($line_item, $payment), 0, 127); |
|
171 | 171 | // Item description. |
172 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc( $line_item, $payment), 0, 127); |
|
172 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($this->_format_line_item_desc($line_item, $payment), 0, 127); |
|
173 | 173 | // Cost of individual item. |
174 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
174 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
175 | 175 | // Item Number. |
176 | 176 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
177 | 177 | // Item quantity. |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
189 | 189 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
190 | 190 | |
191 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
191 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
192 | 192 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
193 | 193 | // add the difference as an extra line item. |
194 | - if ( $this->_money->compare_floats( $itemized_sum_diff_from_txn_total, 0, '!=' ) ) { |
|
194 | + if ($this->_money->compare_floats($itemized_sum_diff_from_txn_total, 0, '!=')) { |
|
195 | 195 | // Item Name. |
196 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
196 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
197 | 197 | // Item description. |
198 | 198 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = ''; |
199 | 199 | // Cost of individual item. |
200 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
200 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
201 | 201 | // Item Number. |
202 | 202 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 203 | // Item quantity. |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | } else { |
210 | 210 | // Just one Item. |
211 | 211 | // Item Name. |
212 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( $this->_format_partial_payment_line_item_name($payment), 0, 127 ); |
|
212 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr($this->_format_partial_payment_line_item_name($payment), 0, 127); |
|
213 | 213 | // Item description. |
214 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( $this->_format_partial_payment_line_item_desc($payment), 0, 127 ); |
|
214 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr($this->_format_partial_payment_line_item_desc($payment), 0, 127); |
|
215 | 215 | // Cost of individual item. |
216 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
216 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
217 | 217 | // Item Number. |
218 | 218 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
219 | 219 | // Item quantity. |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | // Digital item is sold. |
222 | 222 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
223 | 223 | // Item's sales S/H and tax amount. |
224 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
224 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
225 | 225 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
226 | 226 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
227 | 227 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
228 | 228 | } |
229 | 229 | // Automatically filling out shipping and contact information. |
230 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
231 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
230 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
231 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
232 | 232 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
233 | 233 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
234 | 234 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
238 | 238 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
239 | 239 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
240 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
240 | + } elseif ( ! $this->_request_shipping_addr) { |
|
241 | 241 | // Do not request shipping details on the PP Checkout page. |
242 | 242 | $token_request_dtls['NOSHIPPING'] = '1'; |
243 | 243 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
244 | 244 | |
245 | 245 | } |
246 | 246 | // Used a business/personal logo on the PayPal page. |
247 | - if ( ! empty($this->_image_url) ) { |
|
247 | + if ( ! empty($this->_image_url)) { |
|
248 | 248 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
249 | 249 | } |
250 | 250 | $token_request_dtls = apply_filters( |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | $this |
254 | 254 | ); |
255 | 255 | // Request PayPal token. |
256 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
257 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
258 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
259 | - if ( $token_rstatus['status'] ) { |
|
256 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
257 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
258 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
259 | + if ($token_rstatus['status']) { |
|
260 | 260 | // We got the Token so we may continue with the payment and redirect the client. |
261 | - $payment->set_details( $response_args ); |
|
261 | + $payment->set_details($response_args); |
|
262 | 262 | |
263 | 263 | $gateway_url = $this->_debug_mode ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
264 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
264 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
265 | 265 | } else { |
266 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
267 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
266 | + if (isset($response_args['L_ERRORCODE'])) { |
|
267 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
268 | 268 | } else { |
269 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
269 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
270 | 270 | } |
271 | - $payment->set_details( $response_args ); |
|
272 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
271 | + $payment->set_details($response_args); |
|
272 | + $payment->set_status($this->_pay_model->failed_status()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | return $payment; |
@@ -285,22 +285,22 @@ discard block |
||
285 | 285 | * @param EEI_Transaction $transaction |
286 | 286 | * @return EEI_Payment |
287 | 287 | */ |
288 | - public function handle_payment_update( $update_info, $transaction ) { |
|
288 | + public function handle_payment_update($update_info, $transaction) { |
|
289 | 289 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : null; |
290 | 290 | |
291 | - if ( $payment instanceof EEI_Payment ) { |
|
292 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
291 | + if ($payment instanceof EEI_Payment) { |
|
292 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
293 | 293 | $transaction = $payment->transaction(); |
294 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
295 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
296 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
294 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
295 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
296 | + $payment->set_status($this->_pay_model->failed_status()); |
|
297 | 297 | return $payment; |
298 | 298 | } |
299 | 299 | $primary_registrant = $transaction->primary_registration(); |
300 | 300 | $payment_details = $payment->details(); |
301 | 301 | // Check if we still have the token. |
302 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
303 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
302 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
303 | + $payment->set_status($this->_pay_model->failed_status()); |
|
304 | 304 | return $payment; |
305 | 305 | } |
306 | 306 | |
@@ -309,10 +309,10 @@ discard block |
||
309 | 309 | 'TOKEN' => $payment_details['TOKEN'] |
310 | 310 | ); |
311 | 311 | // Request Customer Details. |
312 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
313 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
314 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
315 | - if ( $cdetails_rstatus['status'] ) { |
|
312 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
313 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
314 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
315 | + if ($cdetails_rstatus['status']) { |
|
316 | 316 | // We got the PayerID so now we can Complete the transaction. |
317 | 317 | $docheckout_request_dtls = array( |
318 | 318 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -323,39 +323,39 @@ discard block |
||
323 | 323 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
324 | 324 | ); |
325 | 325 | // Payment Checkout/Capture. |
326 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
327 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
328 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
329 | - if ( $docheckout_rstatus['status'] ) { |
|
326 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
327 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
328 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
329 | + if ($docheckout_rstatus['status']) { |
|
330 | 330 | // All is well, payment approved. |
331 | 331 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
332 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
333 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0 ); |
|
334 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
335 | - $payment->set_details( $cdata_response_args ); |
|
336 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
337 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
332 | + $payment->set_extra_accntng($primary_registration_code); |
|
333 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? (float) $docheckout_response_args['PAYMENTINFO_0_AMT'] : 0); |
|
334 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
335 | + $payment->set_details($cdata_response_args); |
|
336 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
337 | + $payment->set_status($this->_pay_model->approved_status()); |
|
338 | 338 | } else { |
339 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
340 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
339 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
340 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
341 | 341 | } else { |
342 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
342 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
343 | 343 | } |
344 | - $payment->set_details( $docheckout_response_args ); |
|
345 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
344 | + $payment->set_details($docheckout_response_args); |
|
345 | + $payment->set_status($this->_pay_model->declined_status()); |
|
346 | 346 | } |
347 | 347 | } else { |
348 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
349 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
348 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
349 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
350 | 350 | } else { |
351 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
351 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
352 | 352 | } |
353 | - $payment->set_details( $cdata_response_args ); |
|
354 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
353 | + $payment->set_details($cdata_response_args); |
|
354 | + $payment->set_status($this->_pay_model->failed_status()); |
|
355 | 355 | } |
356 | 356 | } else { |
357 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
358 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
357 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
358 | + $payment->set_status($this->_pay_model->failed_status()); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | return $payment; |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * @param EEI_Payment $payment |
371 | 371 | * @return mixed |
372 | 372 | */ |
373 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
373 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
374 | 374 | $request_dtls = array( |
375 | 375 | 'VERSION' => '204.0', |
376 | - 'USER' => urlencode( $this->_api_username ), |
|
377 | - 'PWD' => urlencode( $this->_api_password ), |
|
378 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
376 | + 'USER' => urlencode($this->_api_username), |
|
377 | + 'PWD' => urlencode($this->_api_password), |
|
378 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
379 | 379 | ); |
380 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
380 | + $dtls = array_merge($request_dtls, $request_params); |
|
381 | 381 | |
382 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
382 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
383 | 383 | // Request Customer Details. |
384 | 384 | $request_response = wp_remote_post( |
385 | 385 | $this->_base_gateway_url, |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | 'httpversion' => '1.1', |
390 | 390 | 'cookies' => array(), |
391 | 391 | 'headers' => array(), |
392 | - 'body' => http_build_query( $dtls ) |
|
392 | + 'body' => http_build_query($dtls) |
|
393 | 393 | ) |
394 | 394 | ); |
395 | 395 | // Log the response. |
396 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
396 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
397 | 397 | |
398 | 398 | return $request_response; |
399 | 399 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | * @param mixed $request_response |
406 | 406 | * @return array |
407 | 407 | */ |
408 | - public function _ppExpress_check_response( $request_response ) { |
|
409 | - if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
|
408 | + public function _ppExpress_check_response($request_response) { |
|
409 | + if (is_wp_error($request_response) || empty($request_response['body'])) { |
|
410 | 410 | // If we got here then there was an error in this request. |
411 | 411 | return array('status' => false, 'args' => $request_response); |
412 | 412 | } |
413 | 413 | $response_args = array(); |
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
414 | + parse_str(urldecode($request_response['body']), $response_args); |
|
415 | 415 | if ( ! isset($response_args['ACK'])) { |
416 | 416 | return array('status' => false, 'args' => $request_response); |
417 | 417 | } |
@@ -441,10 +441,10 @@ discard block |
||
441 | 441 | * @param string $info |
442 | 442 | * @return void |
443 | 443 | */ |
444 | - private function _log_clean_request($request, $payment, $info ) { |
|
444 | + private function _log_clean_request($request, $payment, $info) { |
|
445 | 445 | $cleaned_request_data = $request; |
446 | 446 | unset($cleaned_request_data['PWD'], $cleaned_request_data['USER'], $cleaned_request_data['SIGNATURE']); |
447 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
447 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | * @param array $data_array |
455 | 455 | * @return array |
456 | 456 | */ |
457 | - private function _get_errors( $data_array ) { |
|
457 | + private function _get_errors($data_array) { |
|
458 | 458 | $errors = array(); |
459 | 459 | $n = 0; |
460 | - while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
|
460 | + while (isset($data_array["L_ERRORCODE{$n}"])) { |
|
461 | 461 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
462 | 462 | ? $data_array["L_ERRORCODE{$n}"] |
463 | 463 | : ''; |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | ? $data_array["L_LONGMESSAGE{$n}"] |
472 | 472 | : ''; |
473 | 473 | |
474 | - if ( $n === 0 ) { |
|
474 | + if ($n === 0) { |
|
475 | 475 | $errors = array( |
476 | 476 | 'L_ERRORCODE' => $l_error_code, |
477 | 477 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | 'L_SEVERITYCODE' => $l_severity_code |
480 | 480 | ); |
481 | 481 | } else { |
482 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
483 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
484 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
485 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
482 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
483 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
484 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
485 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | $n++; |
@@ -44,77 +44,76 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $_image_url; |
46 | 46 | |
47 | - /** |
|
48 | - * gateway URL variable |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - protected $_base_gateway_url = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * EEG_Paypal_Express constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->_currencies_supported = array( |
|
62 | - 'USD', |
|
63 | - 'AUD', |
|
64 | - 'BRL', |
|
65 | - 'CAD', |
|
66 | - 'CZK', |
|
67 | - 'DKK', |
|
68 | - 'EUR', |
|
69 | - 'HKD', |
|
70 | - 'HUF', |
|
71 | - 'ILS', |
|
72 | - 'JPY', |
|
73 | - 'MYR', |
|
74 | - 'MXN', |
|
75 | - 'NOK', |
|
76 | - 'NZD', |
|
77 | - 'PHP', |
|
78 | - 'PLN', |
|
79 | - 'GBP', |
|
80 | - 'RUB', |
|
81 | - 'SGD', |
|
82 | - 'SEK', |
|
83 | - 'CHF', |
|
84 | - 'TWD', |
|
85 | - 'THB', |
|
86 | - 'TRY' |
|
87 | - ); |
|
88 | - parent::__construct(); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
47 | + /** |
|
48 | + * gateway URL variable |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + protected $_base_gateway_url = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * EEG_Paypal_Express constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->_currencies_supported = array( |
|
62 | + 'USD', |
|
63 | + 'AUD', |
|
64 | + 'BRL', |
|
65 | + 'CAD', |
|
66 | + 'CZK', |
|
67 | + 'DKK', |
|
68 | + 'EUR', |
|
69 | + 'HKD', |
|
70 | + 'HUF', |
|
71 | + 'ILS', |
|
72 | + 'JPY', |
|
73 | + 'MYR', |
|
74 | + 'MXN', |
|
75 | + 'NOK', |
|
76 | + 'NZD', |
|
77 | + 'PHP', |
|
78 | + 'PLN', |
|
79 | + 'GBP', |
|
80 | + 'RUB', |
|
81 | + 'SGD', |
|
82 | + 'SEK', |
|
83 | + 'CHF', |
|
84 | + 'TWD', |
|
85 | + 'THB', |
|
86 | + 'TRY' |
|
87 | + ); |
|
88 | + parent::__construct(); |
|
89 | + } |
|
90 | + |
|
95 | 91 | |
92 | + |
|
93 | + /** |
|
94 | + * Sets the gateway URL variable based on whether debug mode is enabled or not. |
|
96 | 95 | * |
97 | 96 | *@param array $settings_array |
98 | 97 | */ |
99 | 98 | public function set_settings( $settings_array ) { |
100 | 99 | parent::set_settings($settings_array); |
101 | 100 | // Redirect URL. |
102 | - $this->_base_gateway_url = $this->_debug_mode |
|
103 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
104 | - : 'https://api-3t.paypal.com/nvp'; |
|
101 | + $this->_base_gateway_url = $this->_debug_mode |
|
102 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
103 | + : 'https://api-3t.paypal.com/nvp'; |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | |
108 | 107 | |
109 | - /** |
|
110 | - * @param EEI_Payment $payment |
|
111 | - * @param array $billing_info |
|
112 | - * @param string $return_url |
|
113 | - * @param string $notify_url |
|
114 | - * @param string $cancel_url |
|
115 | - * @return \EE_Payment|\EEI_Payment |
|
116 | - * @throws \EE_Error |
|
117 | - */ |
|
108 | + /** |
|
109 | + * @param EEI_Payment $payment |
|
110 | + * @param array $billing_info |
|
111 | + * @param string $return_url |
|
112 | + * @param string $notify_url |
|
113 | + * @param string $cancel_url |
|
114 | + * @return \EE_Payment|\EEI_Payment |
|
115 | + * @throws \EE_Error |
|
116 | + */ |
|
118 | 117 | public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
119 | 118 | if ( ! $payment instanceof EEI_Payment ) { |
120 | 119 | $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
@@ -202,9 +201,9 @@ discard block |
||
202 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
203 | 202 | // Item quantity. |
204 | 203 | $token_request_dtls['L_PAYMENTREQUEST_0_QTY'.$item_num] = 1; |
205 | - // Digital item is sold. |
|
206 | - $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
207 | - $item_num++; |
|
204 | + // Digital item is sold. |
|
205 | + $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY'.$item_num] = 'Physical'; |
|
206 | + $item_num++; |
|
208 | 207 | } |
209 | 208 | } else { |
210 | 209 | // Just one Item. |
@@ -277,7 +276,6 @@ discard block |
||
277 | 276 | |
278 | 277 | |
279 | 278 | /** |
280 | - |
|
281 | 279 | * @param array $update_info { |
282 | 280 | * @type string $gateway_txn_id |
283 | 281 | * @type string status an EEMI_Payment status |
@@ -297,8 +295,8 @@ discard block |
||
297 | 295 | return $payment; |
298 | 296 | } |
299 | 297 | $primary_registrant = $transaction->primary_registration(); |
300 | - $payment_details = $payment->details(); |
|
301 | - // Check if we still have the token. |
|
298 | + $payment_details = $payment->details(); |
|
299 | + // Check if we still have the token. |
|
302 | 300 | if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
303 | 301 | $payment->set_status( $this->_pay_model->failed_status() ); |
304 | 302 | return $payment; |
@@ -407,36 +405,36 @@ discard block |
||
407 | 405 | */ |
408 | 406 | public function _ppExpress_check_response( $request_response ) { |
409 | 407 | if ( is_wp_error( $request_response ) || empty($request_response['body']) ) { |
410 | - // If we got here then there was an error in this request. |
|
411 | - return array('status' => false, 'args' => $request_response); |
|
412 | - } |
|
413 | - $response_args = array(); |
|
414 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
415 | - if ( ! isset($response_args['ACK'])) { |
|
416 | - return array('status' => false, 'args' => $request_response); |
|
417 | - } |
|
418 | - if ( |
|
419 | - $response_args['ACK'] === 'Success' |
|
420 | - && ( |
|
421 | - isset($response_args['PAYERID']) |
|
422 | - || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
423 | - || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
424 | - || isset($response_args['TOKEN']) |
|
425 | - ) |
|
426 | - ) { |
|
427 | - // Response status OK, return response parameters for further processing. |
|
428 | - return array('status' => true, 'args' => $response_args); |
|
429 | - } else { |
|
430 | - $errors = $this->_get_errors($response_args); |
|
431 | - return array('status' => false, 'args' => $errors); |
|
432 | - } |
|
408 | + // If we got here then there was an error in this request. |
|
409 | + return array('status' => false, 'args' => $request_response); |
|
410 | + } |
|
411 | + $response_args = array(); |
|
412 | + parse_str( urldecode($request_response['body']), $response_args ); |
|
413 | + if ( ! isset($response_args['ACK'])) { |
|
414 | + return array('status' => false, 'args' => $request_response); |
|
415 | + } |
|
416 | + if ( |
|
417 | + $response_args['ACK'] === 'Success' |
|
418 | + && ( |
|
419 | + isset($response_args['PAYERID']) |
|
420 | + || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
|
421 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
422 | + || isset($response_args['TOKEN']) |
|
423 | + ) |
|
424 | + ) { |
|
425 | + // Response status OK, return response parameters for further processing. |
|
426 | + return array('status' => true, 'args' => $response_args); |
|
427 | + } else { |
|
428 | + $errors = $this->_get_errors($response_args); |
|
429 | + return array('status' => false, 'args' => $errors); |
|
430 | + } |
|
433 | 431 | } |
434 | 432 | |
435 | 433 | |
436 | 434 | /** |
437 | - * Log a "Cleared" request. |
|
438 | - * |
|
439 | - * @param array $request |
|
435 | + * Log a "Cleared" request. |
|
436 | + * |
|
437 | + * @param array $request |
|
440 | 438 | * @param EEI_Payment $payment |
441 | 439 | * @param string $info |
442 | 440 | * @return void |
@@ -459,17 +457,17 @@ discard block |
||
459 | 457 | $n = 0; |
460 | 458 | while ( isset($data_array["L_ERRORCODE{$n}"]) ) { |
461 | 459 | $l_error_code = isset($data_array["L_ERRORCODE{$n}"]) |
462 | - ? $data_array["L_ERRORCODE{$n}"] |
|
463 | - : ''; |
|
460 | + ? $data_array["L_ERRORCODE{$n}"] |
|
461 | + : ''; |
|
464 | 462 | $l_severity_code = isset($data_array["L_SEVERITYCODE{$n}"]) |
465 | - ? $data_array["L_SEVERITYCODE{$n}"] |
|
466 | - : ''; |
|
463 | + ? $data_array["L_SEVERITYCODE{$n}"] |
|
464 | + : ''; |
|
467 | 465 | $l_short_message = isset($data_array["L_SHORTMESSAGE{$n}"]) |
468 | - ? $data_array["L_SHORTMESSAGE{$n}"] |
|
469 | - : ''; |
|
466 | + ? $data_array["L_SHORTMESSAGE{$n}"] |
|
467 | + : ''; |
|
470 | 468 | $l_long_message = isset($data_array["L_LONGMESSAGE{$n}"]) |
471 | - ? $data_array["L_LONGMESSAGE{$n}"] |
|
472 | - : ''; |
|
469 | + ? $data_array["L_LONGMESSAGE{$n}"] |
|
470 | + : ''; |
|
473 | 471 | |
474 | 472 | if ( $n === 0 ) { |
475 | 473 | $errors = array( |
@@ -38,7 +38,7 @@ |
||
38 | 38 | |
39 | 39 | |
40 | 40 | /** |
41 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
41 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | 42 | * or an array of capability strings |
43 | 43 | * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
44 | 44 | * @param int $ID - (optional) ID for item where current_user_can is being called from |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
5 | 5 | |
6 | 6 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -20,72 +20,72 @@ discard block |
||
20 | 20 | class CapCheck implements CapCheckInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string|array $capability |
|
25 | - */ |
|
26 | - private $capability; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $context |
|
30 | - */ |
|
31 | - private $context; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var int|string $ID |
|
35 | - */ |
|
36 | - private $ID; |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | - * or an array of capability strings |
|
43 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
44 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
45 | - * @throws InvalidDataTypeException |
|
46 | - */ |
|
47 | - public function __construct($capability, $context, $ID = 0) |
|
48 | - { |
|
49 | - if ( ! is_string($capability)) { |
|
50 | - throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
51 | - } |
|
52 | - if ( ! is_string($context)) { |
|
53 | - throw new InvalidDataTypeException('$context', $context, 'string'); |
|
54 | - } |
|
55 | - $this->capability = $capability; |
|
56 | - $this->context = strtolower(str_replace(' ', '_', $context)); |
|
57 | - $this->ID = $ID; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return string|array |
|
64 | - */ |
|
65 | - public function capability() |
|
66 | - { |
|
67 | - return $this->capability; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function context() |
|
76 | - { |
|
77 | - return $this->context; |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @return int|string |
|
84 | - */ |
|
85 | - public function ID() |
|
86 | - { |
|
87 | - return $this->ID; |
|
88 | - } |
|
23 | + /** |
|
24 | + * @var string|array $capability |
|
25 | + */ |
|
26 | + private $capability; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $context |
|
30 | + */ |
|
31 | + private $context; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var int|string $ID |
|
35 | + */ |
|
36 | + private $ID; |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
42 | + * or an array of capability strings |
|
43 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
44 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
45 | + * @throws InvalidDataTypeException |
|
46 | + */ |
|
47 | + public function __construct($capability, $context, $ID = 0) |
|
48 | + { |
|
49 | + if ( ! is_string($capability)) { |
|
50 | + throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
51 | + } |
|
52 | + if ( ! is_string($context)) { |
|
53 | + throw new InvalidDataTypeException('$context', $context, 'string'); |
|
54 | + } |
|
55 | + $this->capability = $capability; |
|
56 | + $this->context = strtolower(str_replace(' ', '_', $context)); |
|
57 | + $this->ID = $ID; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return string|array |
|
64 | + */ |
|
65 | + public function capability() |
|
66 | + { |
|
67 | + return $this->capability; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function context() |
|
76 | + { |
|
77 | + return $this->context; |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @return int|string |
|
84 | + */ |
|
85 | + public function ID() |
|
86 | + { |
|
87 | + return $this->ID; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | 91 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace EventEspresso\core\services\commands; |
4 | 4 | |
5 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace EventEspresso\core\services\commands; |
4 | 4 | |
5 | 5 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('No direct script access allowed'); |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -16,22 +16,22 @@ discard block |
||
16 | 16 | interface CommandHandlerManagerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param CommandHandlerInterface $command_handler |
|
21 | - * @param string $fqcn_for_command Fully Qualified ClassName for Command |
|
22 | - * @return void |
|
23 | - * @throws InvalidCommandHandlerException |
|
24 | - */ |
|
25 | - public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = ''); |
|
19 | + /** |
|
20 | + * @param CommandHandlerInterface $command_handler |
|
21 | + * @param string $fqcn_for_command Fully Qualified ClassName for Command |
|
22 | + * @return void |
|
23 | + * @throws InvalidCommandHandlerException |
|
24 | + */ |
|
25 | + public function addCommandHandler(CommandHandlerInterface $command_handler, $fqcn_for_command = ''); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param CommandInterface $command |
|
31 | - * @param CommandBusInterface $command_bus |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null); |
|
29 | + /** |
|
30 | + * @param CommandInterface $command |
|
31 | + * @param CommandBusInterface $command_bus |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function getCommandHandler(CommandInterface $command, CommandBusInterface $command_bus = null); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | // End of file CommandHandlerManagerInterface.php |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use EventEspresso\core\services\commands\CommandInterface; |
6 | 6 | |
7 | 7 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
8 | - exit('No direct script access allowed'); |
|
8 | + exit('No direct script access allowed'); |
|
9 | 9 | } |
10 | 10 | |
11 | 11 | |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | interface CommandBusMiddlewareInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @param CommandInterface $command |
|
23 | - * @param Closure $next |
|
24 | - * @return mixed |
|
25 | - */ |
|
26 | - public function handle(CommandInterface $command, Closure $next); |
|
21 | + /** |
|
22 | + * @param CommandInterface $command |
|
23 | + * @param Closure $next |
|
24 | + * @return mixed |
|
25 | + */ |
|
26 | + public function handle(CommandInterface $command, Closure $next); |
|
27 | 27 | |
28 | 28 | } |
29 | 29 | // End of file CommandBusMiddlewareInterface.php |
@@ -20,24 +20,24 @@ |
||
20 | 20 | class AddActionHook implements CommandBusMiddlewareInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @param CommandInterface $command |
|
25 | - * @param Closure $next |
|
26 | - * @return mixed |
|
27 | - */ |
|
28 | - public function handle(CommandInterface $command, Closure $next) |
|
29 | - { |
|
30 | - do_action( |
|
31 | - 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before', |
|
32 | - $command |
|
33 | - ); |
|
34 | - $results = $next($command); |
|
35 | - do_action( |
|
36 | - 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after', |
|
37 | - $command |
|
38 | - ); |
|
39 | - return $results; |
|
40 | - } |
|
23 | + /** |
|
24 | + * @param CommandInterface $command |
|
25 | + * @param Closure $next |
|
26 | + * @return mixed |
|
27 | + */ |
|
28 | + public function handle(CommandInterface $command, Closure $next) |
|
29 | + { |
|
30 | + do_action( |
|
31 | + 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before', |
|
32 | + $command |
|
33 | + ); |
|
34 | + $results = $next($command); |
|
35 | + do_action( |
|
36 | + 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after', |
|
37 | + $command |
|
38 | + ); |
|
39 | + return $results; |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | // End of file AddActionHook.php |
43 | 43 | // Location: EventEspresso\core\services\commands\middleware/AddActionHook.php |
44 | 44 | \ No newline at end of file |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | namespace EventEspresso\core\services\commands; |
4 | 4 | |
5 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace EventEspresso\core\services\commands; |
4 | 4 | |
5 | 5 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
6 | - exit('No direct script access allowed'); |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | |
@@ -21,59 +21,59 @@ discard block |
||
21 | 21 | abstract class CompositeCommandHandler extends CommandHandler |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @type CommandBusInterface $command_bus |
|
26 | - */ |
|
27 | - private $command_bus; |
|
24 | + /** |
|
25 | + * @type CommandBusInterface $command_bus |
|
26 | + */ |
|
27 | + private $command_bus; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @type CommandFactoryInterface $command_factory |
|
31 | - */ |
|
32 | - private $command_factory; |
|
29 | + /** |
|
30 | + * @type CommandFactoryInterface $command_factory |
|
31 | + */ |
|
32 | + private $command_factory; |
|
33 | 33 | |
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * CompositeCommandHandler constructor. |
|
38 | - * |
|
39 | - * @param CommandBusInterface $command_bus |
|
40 | - * @param CommandFactoryInterface $command_factory |
|
41 | - */ |
|
42 | - public function __construct(CommandBusInterface $command_bus, CommandFactoryInterface $command_factory) |
|
43 | - { |
|
44 | - $this->command_bus = $command_bus; |
|
45 | - $this->command_factory = $command_factory; |
|
46 | - } |
|
36 | + /** |
|
37 | + * CompositeCommandHandler constructor. |
|
38 | + * |
|
39 | + * @param CommandBusInterface $command_bus |
|
40 | + * @param CommandFactoryInterface $command_factory |
|
41 | + */ |
|
42 | + public function __construct(CommandBusInterface $command_bus, CommandFactoryInterface $command_factory) |
|
43 | + { |
|
44 | + $this->command_bus = $command_bus; |
|
45 | + $this->command_factory = $command_factory; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param CommandBusInterface $command_bus |
|
52 | - */ |
|
53 | - public function setCommandBus(CommandBusInterface $command_bus) |
|
54 | - { |
|
55 | - $this->command_bus = $command_bus; |
|
56 | - } |
|
50 | + /** |
|
51 | + * @param CommandBusInterface $command_bus |
|
52 | + */ |
|
53 | + public function setCommandBus(CommandBusInterface $command_bus) |
|
54 | + { |
|
55 | + $this->command_bus = $command_bus; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * @return CommandBusInterface |
|
62 | - */ |
|
63 | - public function commandBus() |
|
64 | - { |
|
65 | - return $this->command_bus; |
|
66 | - } |
|
60 | + /** |
|
61 | + * @return CommandBusInterface |
|
62 | + */ |
|
63 | + public function commandBus() |
|
64 | + { |
|
65 | + return $this->command_bus; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * @return CommandFactoryInterface |
|
72 | - */ |
|
73 | - public function commandFactory() |
|
74 | - { |
|
75 | - return $this->command_factory; |
|
76 | - } |
|
70 | + /** |
|
71 | + * @return CommandFactoryInterface |
|
72 | + */ |
|
73 | + public function commandFactory() |
|
74 | + { |
|
75 | + return $this->command_factory; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 |
@@ -20,26 +20,26 @@ |
||
20 | 20 | interface CapabilitiesCheckerInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
25 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
26 | - * |
|
27 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
28 | - * @return bool |
|
29 | - * @throws InvalidClassException |
|
30 | - * @throws InsufficientPermissionsException |
|
31 | - */ |
|
32 | - public function processCapCheck($cap_check); |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
38 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
39 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
40 | - * @return bool |
|
41 | - * @throws InsufficientPermissionsException |
|
42 | - * @throws InvalidClassException |
|
43 | - */ |
|
44 | - public function process($capability, $context, $ID = 0); |
|
23 | + /** |
|
24 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
25 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
26 | + * |
|
27 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
28 | + * @return bool |
|
29 | + * @throws InvalidClassException |
|
30 | + * @throws InsufficientPermissionsException |
|
31 | + */ |
|
32 | + public function processCapCheck($cap_check); |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
38 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
39 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
40 | + * @return bool |
|
41 | + * @throws InsufficientPermissionsException |
|
42 | + * @throws InvalidClassException |
|
43 | + */ |
|
44 | + public function process($capability, $context, $ID = 0); |
|
45 | 45 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
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 | |
@@ -24,92 +24,92 @@ discard block |
||
24 | 24 | class CapabilitiesChecker implements CapabilitiesCheckerInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @type EE_Capabilities $capabilities |
|
29 | - */ |
|
30 | - private $capabilities; |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * CapabilitiesChecker constructor |
|
36 | - * |
|
37 | - * @param EE_Capabilities $capabilities |
|
38 | - */ |
|
39 | - public function __construct(EE_Capabilities $capabilities) |
|
40 | - { |
|
41 | - $this->capabilities = $capabilities; |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @return EE_Capabilities |
|
48 | - */ |
|
49 | - protected function capabilities() |
|
50 | - { |
|
51 | - return $this->capabilities; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
58 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
59 | - * |
|
60 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
61 | - * @return bool |
|
62 | - * @throws InvalidClassException |
|
63 | - * @throws InsufficientPermissionsException |
|
64 | - */ |
|
65 | - public function processCapCheck($cap_check) |
|
66 | - { |
|
67 | - if (is_array($cap_check)) { |
|
68 | - foreach ($cap_check as $check) { |
|
69 | - $this->processCapCheck($check); |
|
70 | - } |
|
71 | - return true; |
|
72 | - } |
|
73 | - // at this point, $cap_check should be an individual instance of CapCheck |
|
74 | - if (! $cap_check instanceof CapCheckInterface) { |
|
75 | - throw new InvalidClassException( |
|
76 | - '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
77 | - ); |
|
78 | - } |
|
79 | - // sometimes cap checks are conditional, and no capabilities are required |
|
80 | - if ($cap_check instanceof PublicCapabilities) { |
|
81 | - return true; |
|
82 | - } |
|
83 | - $capabilities = (array)$cap_check->capability(); |
|
84 | - foreach ($capabilities as $capability) { |
|
85 | - if ( |
|
86 | - ! $this->capabilities()->current_user_can( |
|
87 | - $capability, |
|
88 | - $cap_check->context(), |
|
89 | - $cap_check->ID() |
|
90 | - ) |
|
91 | - ) { |
|
92 | - throw new InsufficientPermissionsException($cap_check->context()); |
|
93 | - } |
|
94 | - } |
|
95 | - return true; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
102 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
103 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
104 | - * @return bool |
|
105 | - * @throws InvalidDataTypeException |
|
106 | - * @throws InsufficientPermissionsException |
|
107 | - * @throws InvalidClassException |
|
108 | - */ |
|
109 | - public function process($capability, $context, $ID = 0) |
|
110 | - { |
|
111 | - return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
112 | - } |
|
27 | + /** |
|
28 | + * @type EE_Capabilities $capabilities |
|
29 | + */ |
|
30 | + private $capabilities; |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * CapabilitiesChecker constructor |
|
36 | + * |
|
37 | + * @param EE_Capabilities $capabilities |
|
38 | + */ |
|
39 | + public function __construct(EE_Capabilities $capabilities) |
|
40 | + { |
|
41 | + $this->capabilities = $capabilities; |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @return EE_Capabilities |
|
48 | + */ |
|
49 | + protected function capabilities() |
|
50 | + { |
|
51 | + return $this->capabilities; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
58 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
59 | + * |
|
60 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
61 | + * @return bool |
|
62 | + * @throws InvalidClassException |
|
63 | + * @throws InsufficientPermissionsException |
|
64 | + */ |
|
65 | + public function processCapCheck($cap_check) |
|
66 | + { |
|
67 | + if (is_array($cap_check)) { |
|
68 | + foreach ($cap_check as $check) { |
|
69 | + $this->processCapCheck($check); |
|
70 | + } |
|
71 | + return true; |
|
72 | + } |
|
73 | + // at this point, $cap_check should be an individual instance of CapCheck |
|
74 | + if (! $cap_check instanceof CapCheckInterface) { |
|
75 | + throw new InvalidClassException( |
|
76 | + '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
77 | + ); |
|
78 | + } |
|
79 | + // sometimes cap checks are conditional, and no capabilities are required |
|
80 | + if ($cap_check instanceof PublicCapabilities) { |
|
81 | + return true; |
|
82 | + } |
|
83 | + $capabilities = (array)$cap_check->capability(); |
|
84 | + foreach ($capabilities as $capability) { |
|
85 | + if ( |
|
86 | + ! $this->capabilities()->current_user_can( |
|
87 | + $capability, |
|
88 | + $cap_check->context(), |
|
89 | + $cap_check->ID() |
|
90 | + ) |
|
91 | + ) { |
|
92 | + throw new InsufficientPermissionsException($cap_check->context()); |
|
93 | + } |
|
94 | + } |
|
95 | + return true; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
102 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
103 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
104 | + * @return bool |
|
105 | + * @throws InvalidDataTypeException |
|
106 | + * @throws InsufficientPermissionsException |
|
107 | + * @throws InvalidClassException |
|
108 | + */ |
|
109 | + public function process($capability, $context, $ID = 0) |
|
110 | + { |
|
111 | + return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use EventEspresso\core\exceptions\InvalidClassException; |
8 | 8 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
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 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return true; |
72 | 72 | } |
73 | 73 | // at this point, $cap_check should be an individual instance of CapCheck |
74 | - if (! $cap_check instanceof CapCheckInterface) { |
|
74 | + if ( ! $cap_check instanceof CapCheckInterface) { |
|
75 | 75 | throw new InvalidClassException( |
76 | 76 | '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
77 | 77 | ); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | if ($cap_check instanceof PublicCapabilities) { |
81 | 81 | return true; |
82 | 82 | } |
83 | - $capabilities = (array)$cap_check->capability(); |
|
83 | + $capabilities = (array) $cap_check->capability(); |
|
84 | 84 | foreach ($capabilities as $capability) { |
85 | 85 | if ( |
86 | 86 | ! $this->capabilities()->current_user_can( |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\services\loaders\LoaderInterface; |
5 | 5 | |
6 | 6 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
7 | - exit('No direct script access allowed'); |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -24,228 +24,228 @@ discard block |
||
24 | 24 | class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @type LoaderInterface $loader |
|
29 | - */ |
|
30 | - protected $loader; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var EE_Request $request |
|
34 | - */ |
|
35 | - protected $request; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Response $response |
|
39 | - */ |
|
40 | - protected $response; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Dependency_Map $dependency_map |
|
44 | - */ |
|
45 | - protected $dependency_map; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Registry $registry |
|
49 | - */ |
|
50 | - protected $registry; |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * EE_Load_Espresso_Core constructor |
|
56 | - */ |
|
57 | - public function __construct() |
|
58 | - { |
|
59 | - espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * handle |
|
66 | - * sets hooks for running rest of system |
|
67 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
68 | - * starting EE Addons from any other point may lead to problems |
|
69 | - * |
|
70 | - * @param EE_Request $request |
|
71 | - * @param EE_Response $response |
|
72 | - * @return EE_Response |
|
73 | - * @throws EE_Error |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws InvalidInterfaceException |
|
76 | - * @throws InvalidArgumentException |
|
77 | - */ |
|
78 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
79 | - { |
|
80 | - $this->request = $request; |
|
81 | - $this->response = $response; |
|
82 | - // info about how to load classes required by other classes |
|
83 | - $this->dependency_map = $this->_load_dependency_map(); |
|
84 | - // central repository for classes |
|
85 | - $this->registry = $this->_load_registry(); |
|
86 | - do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
87 | - // PSR4 Autoloaders |
|
88 | - $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
89 | - $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader'); |
|
90 | - $this->dependency_map->setLoader($this->loader); |
|
91 | - // build DI container |
|
92 | - $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
93 | - $OpenCoffeeShop->addRecipes(); |
|
94 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
95 | - // create and cache the CommandBus, and also add middleware |
|
96 | - $this->registry->create( |
|
97 | - 'CommandBusInterface', |
|
98 | - array( |
|
99 | - null, |
|
100 | - apply_filters( |
|
101 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
102 | - array( |
|
103 | - $this->registry->create('CapChecker'), |
|
104 | - $this->registry->create('AddActionHook'), |
|
105 | - ) |
|
106 | - ), |
|
107 | - ), |
|
108 | - true |
|
109 | - ); |
|
110 | - // workarounds for PHP < 5.3 |
|
111 | - $this->_load_class_tools(); |
|
112 | - // load interfaces |
|
113 | - espresso_load_required('EEI_Payment_Method_Interfaces', |
|
114 | - EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
115 | - // deprecated functions |
|
116 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
117 | - // WP cron jobs |
|
118 | - $this->registry->load_core('Cron_Tasks'); |
|
119 | - $this->registry->load_core('EE_Request_Handler'); |
|
120 | - $this->registry->load_core('EE_System'); |
|
121 | - return $this->response; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return EE_Request |
|
128 | - */ |
|
129 | - public function request() |
|
130 | - { |
|
131 | - return $this->request; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @return EE_Response |
|
138 | - */ |
|
139 | - public function response() |
|
140 | - { |
|
141 | - return $this->response; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return EE_Dependency_Map |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - public function dependency_map() |
|
151 | - { |
|
152 | - if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
153 | - throw new EE_Error( |
|
154 | - sprintf( |
|
155 | - __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
156 | - print_r($this->dependency_map, true) |
|
157 | - ) |
|
158 | - ); |
|
159 | - } |
|
160 | - return $this->dependency_map; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @return EE_Registry |
|
167 | - * @throws EE_Error |
|
168 | - */ |
|
169 | - public function registry() |
|
170 | - { |
|
171 | - if (! $this->registry instanceof EE_Registry) { |
|
172 | - throw new EE_Error( |
|
173 | - sprintf( |
|
174 | - __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
175 | - print_r($this->registry, true) |
|
176 | - ) |
|
177 | - ); |
|
178 | - } |
|
179 | - return $this->registry; |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * @return EE_Dependency_Map |
|
186 | - */ |
|
187 | - private function _load_dependency_map() |
|
188 | - { |
|
189 | - if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
190 | - EE_Error::add_error( |
|
191 | - __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
192 | - __FILE__, __FUNCTION__, __LINE__ |
|
193 | - ); |
|
194 | - wp_die(EE_Error::get_notices()); |
|
195 | - } |
|
196 | - require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
197 | - return EE_Dependency_Map::instance($this->request, $this->response); |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @return EE_Registry |
|
204 | - */ |
|
205 | - private function _load_registry() |
|
206 | - { |
|
207 | - if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
208 | - EE_Error::add_error( |
|
209 | - __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
210 | - __FILE__, __FUNCTION__, __LINE__ |
|
211 | - ); |
|
212 | - wp_die(EE_Error::get_notices()); |
|
213 | - } |
|
214 | - require_once(EE_CORE . 'EE_Registry.core.php'); |
|
215 | - return EE_Registry::instance($this->dependency_map); |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * @return void |
|
222 | - */ |
|
223 | - private function _load_class_tools() |
|
224 | - { |
|
225 | - if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
226 | - EE_Error::add_error( |
|
227 | - __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
228 | - __FILE__, __FUNCTION__, __LINE__ |
|
229 | - ); |
|
230 | - } |
|
231 | - require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * called after the request stack has been fully processed |
|
238 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
239 | - * |
|
240 | - * @param EE_Request $request |
|
241 | - * @param EE_Response $response |
|
242 | - */ |
|
243 | - public function handle_response(EE_Request $request, EE_Response $response) |
|
244 | - { |
|
245 | - if ($response->plugin_deactivated()) { |
|
246 | - espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
247 | - } |
|
248 | - } |
|
27 | + /** |
|
28 | + * @type LoaderInterface $loader |
|
29 | + */ |
|
30 | + protected $loader; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var EE_Request $request |
|
34 | + */ |
|
35 | + protected $request; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Response $response |
|
39 | + */ |
|
40 | + protected $response; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Dependency_Map $dependency_map |
|
44 | + */ |
|
45 | + protected $dependency_map; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Registry $registry |
|
49 | + */ |
|
50 | + protected $registry; |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * EE_Load_Espresso_Core constructor |
|
56 | + */ |
|
57 | + public function __construct() |
|
58 | + { |
|
59 | + espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * handle |
|
66 | + * sets hooks for running rest of system |
|
67 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
68 | + * starting EE Addons from any other point may lead to problems |
|
69 | + * |
|
70 | + * @param EE_Request $request |
|
71 | + * @param EE_Response $response |
|
72 | + * @return EE_Response |
|
73 | + * @throws EE_Error |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws InvalidInterfaceException |
|
76 | + * @throws InvalidArgumentException |
|
77 | + */ |
|
78 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
79 | + { |
|
80 | + $this->request = $request; |
|
81 | + $this->response = $response; |
|
82 | + // info about how to load classes required by other classes |
|
83 | + $this->dependency_map = $this->_load_dependency_map(); |
|
84 | + // central repository for classes |
|
85 | + $this->registry = $this->_load_registry(); |
|
86 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
87 | + // PSR4 Autoloaders |
|
88 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
89 | + $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader'); |
|
90 | + $this->dependency_map->setLoader($this->loader); |
|
91 | + // build DI container |
|
92 | + $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
93 | + $OpenCoffeeShop->addRecipes(); |
|
94 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
95 | + // create and cache the CommandBus, and also add middleware |
|
96 | + $this->registry->create( |
|
97 | + 'CommandBusInterface', |
|
98 | + array( |
|
99 | + null, |
|
100 | + apply_filters( |
|
101 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
102 | + array( |
|
103 | + $this->registry->create('CapChecker'), |
|
104 | + $this->registry->create('AddActionHook'), |
|
105 | + ) |
|
106 | + ), |
|
107 | + ), |
|
108 | + true |
|
109 | + ); |
|
110 | + // workarounds for PHP < 5.3 |
|
111 | + $this->_load_class_tools(); |
|
112 | + // load interfaces |
|
113 | + espresso_load_required('EEI_Payment_Method_Interfaces', |
|
114 | + EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
115 | + // deprecated functions |
|
116 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
117 | + // WP cron jobs |
|
118 | + $this->registry->load_core('Cron_Tasks'); |
|
119 | + $this->registry->load_core('EE_Request_Handler'); |
|
120 | + $this->registry->load_core('EE_System'); |
|
121 | + return $this->response; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return EE_Request |
|
128 | + */ |
|
129 | + public function request() |
|
130 | + { |
|
131 | + return $this->request; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @return EE_Response |
|
138 | + */ |
|
139 | + public function response() |
|
140 | + { |
|
141 | + return $this->response; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return EE_Dependency_Map |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + public function dependency_map() |
|
151 | + { |
|
152 | + if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
153 | + throw new EE_Error( |
|
154 | + sprintf( |
|
155 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
156 | + print_r($this->dependency_map, true) |
|
157 | + ) |
|
158 | + ); |
|
159 | + } |
|
160 | + return $this->dependency_map; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @return EE_Registry |
|
167 | + * @throws EE_Error |
|
168 | + */ |
|
169 | + public function registry() |
|
170 | + { |
|
171 | + if (! $this->registry instanceof EE_Registry) { |
|
172 | + throw new EE_Error( |
|
173 | + sprintf( |
|
174 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
175 | + print_r($this->registry, true) |
|
176 | + ) |
|
177 | + ); |
|
178 | + } |
|
179 | + return $this->registry; |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * @return EE_Dependency_Map |
|
186 | + */ |
|
187 | + private function _load_dependency_map() |
|
188 | + { |
|
189 | + if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
190 | + EE_Error::add_error( |
|
191 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
192 | + __FILE__, __FUNCTION__, __LINE__ |
|
193 | + ); |
|
194 | + wp_die(EE_Error::get_notices()); |
|
195 | + } |
|
196 | + require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
197 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @return EE_Registry |
|
204 | + */ |
|
205 | + private function _load_registry() |
|
206 | + { |
|
207 | + if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
208 | + EE_Error::add_error( |
|
209 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
210 | + __FILE__, __FUNCTION__, __LINE__ |
|
211 | + ); |
|
212 | + wp_die(EE_Error::get_notices()); |
|
213 | + } |
|
214 | + require_once(EE_CORE . 'EE_Registry.core.php'); |
|
215 | + return EE_Registry::instance($this->dependency_map); |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * @return void |
|
222 | + */ |
|
223 | + private function _load_class_tools() |
|
224 | + { |
|
225 | + if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
226 | + EE_Error::add_error( |
|
227 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
228 | + __FILE__, __FUNCTION__, __LINE__ |
|
229 | + ); |
|
230 | + } |
|
231 | + require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * called after the request stack has been fully processed |
|
238 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
239 | + * |
|
240 | + * @param EE_Request $request |
|
241 | + * @param EE_Response $response |
|
242 | + */ |
|
243 | + public function handle_response(EE_Request $request, EE_Response $response) |
|
244 | + { |
|
245 | + if ($response->plugin_deactivated()) { |
|
246 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
247 | + } |
|
248 | + } |
|
249 | 249 | |
250 | 250 | |
251 | 251 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
4 | 4 | use EventEspresso\core\services\loaders\LoaderInterface; |
5 | 5 | |
6 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | 7 | exit('No direct script access allowed'); |
8 | 8 | } |
9 | 9 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function __construct() |
58 | 58 | { |
59 | - espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
59 | + espresso_load_required('EventEspresso\core\Factory', EE_CORE.'Factory.php'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | $this->_load_class_tools(); |
112 | 112 | // load interfaces |
113 | 113 | espresso_load_required('EEI_Payment_Method_Interfaces', |
114 | - EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
114 | + EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php'); |
|
115 | 115 | // deprecated functions |
116 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
116 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
117 | 117 | // WP cron jobs |
118 | 118 | $this->registry->load_core('Cron_Tasks'); |
119 | 119 | $this->registry->load_core('EE_Request_Handler'); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function dependency_map() |
151 | 151 | { |
152 | - if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
152 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
153 | 153 | throw new EE_Error( |
154 | 154 | sprintf( |
155 | 155 | __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function registry() |
170 | 170 | { |
171 | - if (! $this->registry instanceof EE_Registry) { |
|
171 | + if ( ! $this->registry instanceof EE_Registry) { |
|
172 | 172 | throw new EE_Error( |
173 | 173 | sprintf( |
174 | 174 | __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | */ |
187 | 187 | private function _load_dependency_map() |
188 | 188 | { |
189 | - if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
189 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
190 | 190 | EE_Error::add_error( |
191 | 191 | __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
192 | 192 | __FILE__, __FUNCTION__, __LINE__ |
193 | 193 | ); |
194 | 194 | wp_die(EE_Error::get_notices()); |
195 | 195 | } |
196 | - require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
196 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
197 | 197 | return EE_Dependency_Map::instance($this->request, $this->response); |
198 | 198 | } |
199 | 199 | |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | */ |
205 | 205 | private function _load_registry() |
206 | 206 | { |
207 | - if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
207 | + if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) { |
|
208 | 208 | EE_Error::add_error( |
209 | 209 | __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
210 | 210 | __FILE__, __FUNCTION__, __LINE__ |
211 | 211 | ); |
212 | 212 | wp_die(EE_Error::get_notices()); |
213 | 213 | } |
214 | - require_once(EE_CORE . 'EE_Registry.core.php'); |
|
214 | + require_once(EE_CORE.'EE_Registry.core.php'); |
|
215 | 215 | return EE_Registry::instance($this->dependency_map); |
216 | 216 | } |
217 | 217 | |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | */ |
223 | 223 | private function _load_class_tools() |
224 | 224 | { |
225 | - if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
225 | + if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) { |
|
226 | 226 | EE_Error::add_error( |
227 | 227 | __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
228 | 228 | __FILE__, __FUNCTION__, __LINE__ |
229 | 229 | ); |
230 | 230 | } |
231 | - require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
231 | + require_once(EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 |