Completed
Branch FET-10416-autoload-b4-bootstra... (82e972)
by
unknown
27:05 queued 13:30
created
core/db_models/EEM_Payment_Method.model.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  *
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
 	 * @access   protected
38 38
 	 * @return EEM_Payment_Method
39 39
 	 */
40
-	protected function __construct( $timezone = NULL ) {
41
-		$this->singlular_item = __( 'Payment Method', 'event_espresso' );
42
-		$this->plural_item = __( 'Payment Methods', 'event_espresso' );
43
-		$this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) );
40
+	protected function __construct($timezone = NULL) {
41
+		$this->singlular_item = __('Payment Method', 'event_espresso');
42
+		$this->plural_item = __('Payment Methods', 'event_espresso');
43
+		$this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID'));
44 44
 		$this->_fields = array(
45 45
 			'Payment_Method' => array(
46
-				'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ),
47
-				'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ),
48
-				'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ),
49
-				'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ),
50
-				'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ),
51
-				'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ),
52
-				'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ),
53
-				'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ),
54
-				'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ),
55
-				'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ),
56
-				'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ),
57
-				'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API'
46
+				'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')),
47
+				'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'),
48
+				'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE),
49
+				'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''),
50
+				'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE),
51
+				'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE),
52
+				'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE),
53
+				'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0),
54
+				'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE),
55
+				'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE),
56
+				'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''),
57
+				'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API'
58 58
 		) );
59 59
 		$this->_model_relations = array(
60 60
  //			'Event'=>new EE_HABTM_Relation('Event_Payment_Method'),
61 61
 			'Payment' => new EE_Has_Many_Relation(),
62
-			'Currency' => new EE_HABTM_Relation( 'Currency_Payment_Method' ),
62
+			'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'),
63 63
 			'Transaction' => new EE_Has_Many_Relation(),
64 64
 			'WP_User' => new EE_Belongs_To_Relation(),
65 65
 		);
66
-		parent::__construct( $timezone );
66
+		parent::__construct($timezone);
67 67
 	}
68 68
 
69 69
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @param string $slug
74 74
 	 * @return EE_Payment_Method
75 75
 	 */
76
-	public function get_one_by_slug( $slug ) {
77
-		return $this->get_one( array( array( 'PMD_slug' => $slug ) ) );
76
+	public function get_one_by_slug($slug) {
77
+		return $this->get_one(array(array('PMD_slug' => $slug)));
78 78
 	}
79 79
 
80 80
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		return apply_filters(
89 89
 			'FHEE__EEM_Payment_Method__scopes',
90 90
 			array(
91
-				self::scope_cart 		=> __( "Front-end Registration Page", 'event_espresso' ),
92
-				self::scope_admin 	=> __( "Admin Registration Page (no online processing)", 'event_espresso' )
91
+				self::scope_cart 		=> __("Front-end Registration Page", 'event_espresso'),
92
+				self::scope_admin 	=> __("Admin Registration Page (no online processing)", 'event_espresso')
93 93
 			)
94 94
 		);
95 95
 	}
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param string $scope like one of EEM_Payment_Method::instance()->scopes()
102 102
 	 * @return boolean
103 103
 	 */
104
-	public function is_valid_scope( $scope ) {
104
+	public function is_valid_scope($scope) {
105 105
 		$scopes = $this->scopes();
106
-		if ( isset( $scopes[ $scope ] ) ) {
106
+		if (isset($scopes[$scope])) {
107 107
 			return TRUE;
108 108
 		} else {
109 109
 			return FALSE;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * @throws EE_Error
120 120
 	 * @return EE_Payment_Method[]
121 121
 	 */
122
-	public function get_all_active( $scope = NULL, $query_params = array() ) {
123
-		if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) {
124
-			$query_params['order_by'] = array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' );
122
+	public function get_all_active($scope = NULL, $query_params = array()) {
123
+		if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) {
124
+			$query_params['order_by'] = array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC');
125 125
 		}
126
-		return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) );
126
+		return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params));
127 127
 	}
128 128
 
129 129
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 * @param array $query_params
133 133
 	 * @return int
134 134
 	 */
135
-	public function count_active( $scope = NULL, $query_params = array() ){
136
-		return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) );
135
+	public function count_active($scope = NULL, $query_params = array()) {
136
+		return $this->count($this->_get_query_params_for_all_active($scope, $query_params));
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 	 * @return array like param of EEM_Base::get_all()
145 145
 	 * @throws EE_Error
146 146
 	 */
147
-	protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){
148
-		if ( $scope ) {
149
-			if ( $this->is_valid_scope( $scope ) ) {
150
-				return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params );
147
+	protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) {
148
+		if ($scope) {
149
+			if ($this->is_valid_scope($scope)) {
150
+				return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params);
151 151
 			} else {
152
-				throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) );
152
+				throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope));
153 153
 			}
154 154
 		} else {
155 155
 			$acceptable_scopes = array();
156 156
 			$count = 0;
157
-			foreach ( $this->scopes() as $scope_name => $desc ) {
157
+			foreach ($this->scopes() as $scope_name => $desc) {
158 158
 				$count++;
159
-				$acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' );
159
+				$acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%');
160 160
 			}
161
-			return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params );
161
+			return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params);
162 162
 		}
163 163
 	}
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @return array like param of EEM_Base::get_all()
171 171
 	 * @throws EE_Error
172 172
 	 */
173
-	public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) {
174
-		return $this->_get_query_params_for_all_active( $scope, $query_params );
173
+	public function get_query_params_for_all_active($scope = NULL, $query_params = array()) {
174
+		return $this->_get_query_params_for_all_active($scope, $query_params);
175 175
 	}
176 176
 
177 177
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param array  $query_params
182 182
 	 * @return EE_Payment_Method
183 183
 	 */
184
-	public function get_one_active( $scope = NULL, $query_params = array() ) {
185
-		return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) );
184
+	public function get_one_active($scope = NULL, $query_params = array()) {
185
+		return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params));
186 186
 	}
187 187
 
188 188
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param string $type
193 193
 	 * @return EE_Payment_Method
194 194
 	 */
195
-	public function get_one_of_type( $type ) {
196
-		return $this->get_one( array( array( 'PMD_type' => $type ) ) );
195
+	public function get_one_of_type($type) {
196
+		return $this->get_one(array(array('PMD_type' => $type)));
197 197
 	}
198 198
 
199 199
 
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
 	 * @return EE_Payment_Method
207 207
 	 * @throws EE_Error
208 208
 	 */
209
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) {
209
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
210 210
 		//first: check if it's a slug
211
-		if( is_string( $base_class_obj_or_id ) ) {
212
-			$obj = $this->get_one_by_slug( $base_class_obj_or_id );
213
-			if( $obj ) {
211
+		if (is_string($base_class_obj_or_id)) {
212
+			$obj = $this->get_one_by_slug($base_class_obj_or_id);
213
+			if ($obj) {
214 214
 				return $obj;
215 215
 			}
216 216
 		}
217 217
 		//ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID)
218 218
 		try {
219
-			return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db );
219
+			return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db);
220 220
 		}
221
-		catch ( EE_Error $e ) {
221
+		catch (EE_Error $e) {
222 222
 			//handle it outside the catch
223 223
 		}
224
-		throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) );
224
+		throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id));
225 225
 	}
226 226
 
227 227
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 * @param mixed $base_obj_or_id_or_slug
233 233
 	 * @return int
234 234
 	 */
235
-	function ensure_is_ID( $base_obj_or_id_or_slug ) {
236
-		if ( is_string( $base_obj_or_id_or_slug ) ) {
235
+	function ensure_is_ID($base_obj_or_id_or_slug) {
236
+		if (is_string($base_obj_or_id_or_slug)) {
237 237
 			//assume it's a slug
238
-			$base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug );
238
+			$base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug);
239 239
 		}
240
-		return parent::ensure_is_ID( $base_obj_or_id_or_slug );
240
+		return parent::ensure_is_ID($base_obj_or_id_or_slug);
241 241
 	}
242 242
 
243 243
 
@@ -246,36 +246,36 @@  discard block
 block discarded – undo
246 246
 	 * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default.
247 247
 	 * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart
248 248
 	 */
249
-	function verify_button_urls( $payment_methods = NULL ) {
250
-		$payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
251
-		foreach ( $payment_methods as $payment_method ) {
249
+	function verify_button_urls($payment_methods = NULL) {
250
+		$payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
251
+		foreach ($payment_methods as $payment_method) {
252 252
 			try {
253 253
 				$current_button_url = $payment_method->button_url();
254
-				$buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array(
255
-					'current_ssl' => str_replace( "http://", "https://", $current_button_url ),
256
-					'current' => str_replace( "https://", "http://", $current_button_url ),
257
-					'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ),
258
-					'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ),
259
-				) );
260
-				foreach( $buttons_urls_to_try as $button_url_to_try ) {
261
-					if(
254
+				$buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array(
255
+					'current_ssl' => str_replace("http://", "https://", $current_button_url),
256
+					'current' => str_replace("https://", "http://", $current_button_url),
257
+					'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()),
258
+					'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()),
259
+				));
260
+				foreach ($buttons_urls_to_try as $button_url_to_try) {
261
+					if (
262 262
 							(//this is the current url and it exists, regardless of SSL issues
263 263
 								$button_url_to_try == $current_button_url &&
264 264
 								EEH_URL::remote_file_exists(
265 265
 										$button_url_to_try,
266 266
 										array(
267 267
 											'sslverify' => false,
268
-											'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
268
+											'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
269 269
 											) )
270 270
 							)
271 271
 							||
272 272
 							(//this is NOT the current url and it exists with a working SSL cert
273 273
 								$button_url_to_try != $current_button_url &&
274
-								EEH_URL::remote_file_exists( $button_url_to_try )
274
+								EEH_URL::remote_file_exists($button_url_to_try)
275 275
 							) ) {
276
-						if( $current_button_url != $button_url_to_try ){
277
-							$payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) );
278
-							EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) );
276
+						if ($current_button_url != $button_url_to_try) {
277
+							$payment_method->save(array('PMD_button_url' => $button_url_to_try));
278
+							EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try));
279 279
 						}
280 280
 						//this image exists. So if wasn't set before, now it is;
281 281
 						//or if it was already set, we have nothing to do
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 					}
284 284
 				}
285 285
 			}
286
-			catch ( EE_Error $e ) {
287
-				$payment_method->set_active( FALSE );
286
+			catch (EE_Error $e) {
287
+				$payment_method->set_active(FALSE);
288 288
 			}
289 289
 		}
290 290
 	}
@@ -298,29 +298,29 @@  discard block
 block discarded – undo
298 298
 	 * @param array $rows
299 299
 	 * @return EE_Payment_Method[]
300 300
 	 */
301
-	protected function _create_objects( $rows = array() ) {
302
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
303
-		$payment_methods = parent::_create_objects( $rows );
301
+	protected function _create_objects($rows = array()) {
302
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
303
+		$payment_methods = parent::_create_objects($rows);
304 304
 		/* @var $payment_methods EE_Payment_Method[] */
305 305
 		$usable_payment_methods = array();
306
-		foreach ( $payment_methods as $key => $payment_method ) {
307
-			if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) {
308
-				$usable_payment_methods[ $key ] = $payment_method;
306
+		foreach ($payment_methods as $key => $payment_method) {
307
+			if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) {
308
+				$usable_payment_methods[$key] = $payment_method;
309 309
 				//some payment methods enqueue their scripts in EE_PMT_*::__construct
310 310
 				//which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue
311 311
 				//its scripts). but for backwards-compat we should continue to do that
312 312
 				$payment_method->type_obj();
313
-			} elseif( $payment_method->active() ) {				
313
+			} elseif ($payment_method->active()) {				
314 314
 				//only deactivate and notify the admin if the payment is active somewhere
315 315
 				$payment_method->deactivate();
316 316
 				$payment_method->save();
317 317
 				EE_Error::add_persistent_admin_notice(
318
-					'auto-deactivated-' . $payment_method->type(),
318
+					'auto-deactivated-'.$payment_method->type(),
319 319
 					sprintf(
320
-						__( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ),
320
+						__('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'),
321 321
 						$payment_method->admin_name(),
322 322
 						'<br />',
323
-						'<a href="' . admin_url('plugins.php') . '">',
323
+						'<a href="'.admin_url('plugins.php').'">',
324 324
 						'</a>'
325 325
 					),
326 326
 					true
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
 	 * @param string 	$scope @see EEM_Payment_Method::get_all_for_events
341 341
 	 * @return EE_Payment_Method[]
342 342
 	 */
343
-	public function get_all_for_transaction( $transaction, $scope ) {
343
+	public function get_all_for_transaction($transaction, $scope) {
344 344
 		//give addons a chance to override what payment methods are chosen based on the transaction
345 345
 		return apply_filters(
346 346
 			'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods',
347
-			$this->get_all_active( $scope, array( 'group_by' => 'PMD_type' ) ),
347
+			$this->get_all_active($scope, array('group_by' => 'PMD_type')),
348 348
 			$transaction,
349 349
 			$scope
350 350
 		);
@@ -360,16 +360,16 @@  discard block
 block discarded – undo
360 360
 	 * @param EE_Registration|int $registration_or_reg_id  Either the EE_Registration object or the id for the registration.
361 361
 	 * @return EE_Payment|null
362 362
 	 */
363
-	public function get_last_used_for_registration( $registration_or_reg_id ) {
364
-		$registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id );
363
+	public function get_last_used_for_registration($registration_or_reg_id) {
364
+		$registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id);
365 365
 
366 366
 		$query_params = array(
367 367
 			0 => array(
368 368
 				'Payment.Registration.REG_ID' => $registration_id,
369 369
 			),
370
-			'order_by' => array( 'Payment.PAY_ID' => 'DESC' )
370
+			'order_by' => array('Payment.PAY_ID' => 'DESC')
371 371
 		);
372
-		return $this->get_one( $query_params );
372
+		return $this->get_one($query_params);
373 373
 	}
374 374
 
375 375
 }
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 		}
21 21
 
22 22
 		if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) {
23
-		    return null;
24
-        }
23
+			return null;
24
+		}
25 25
 
26 26
 		if( ! is_string( $value_to_normalize )){
27 27
 			throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) );
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 	 * @return string
57 57
 	 */
58 58
 	public function unnormalize( $normalized_value ) {
59
-	    if ($normalized_value === null || $normalized_value === '') {
60
-	        return '';
61
-        }elseif( empty( $normalized_value ) ){
59
+		if ($normalized_value === null || $normalized_value === '') {
60
+			return '';
61
+		}elseif( empty( $normalized_value ) ){
62 62
 			return '0';
63 63
 		}else{
64 64
 			return "$normalized_value";
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @subpackage
8 8
  * @author				Mike Nelson
9 9
  */
10
-class EE_Int_Normalization extends EE_Normalization_Strategy_Base{
10
+class EE_Int_Normalization extends EE_Normalization_Strategy_Base {
11 11
 
12 12
 	/**
13 13
 	 * @param string $value_to_normalize
@@ -15,38 +15,38 @@  discard block
 block discarded – undo
15 15
 	 * @throws \EE_Validation_Error
16 16
 	 */
17 17
 	public function normalize($value_to_normalize) {
18
-		if( is_int( $value_to_normalize ) ){
18
+		if (is_int($value_to_normalize)) {
19 19
 			return $value_to_normalize;
20 20
 		}
21 21
 
22
-		if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) {
22
+		if (is_null($value_to_normalize) || $value_to_normalize === '') {
23 23
 		    return null;
24 24
         }
25 25
 
26
-		if( ! is_string( $value_to_normalize )){
27
-			throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) );
26
+		if ( ! is_string($value_to_normalize)) {
27
+			throw new EE_Validation_Error(sprintf(__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), print_r($value_to_normalize, TRUE), gettype($value_to_normalize)));
28 28
 		}
29 29
 		$thousands_separator = EE_Config::instance()->currency->thsnds;
30
-		$value_to_normalize = str_replace( $thousands_separator, "", $value_to_normalize );
31
-		$value_to_normalize = str_replace( array(" ","\t"), '', $value_to_normalize );
32
-		if ( preg_match( '/^\d+$/', $value_to_normalize )) {
33
-			return intval( $value_to_normalize );
30
+		$value_to_normalize = str_replace($thousands_separator, "", $value_to_normalize);
31
+		$value_to_normalize = str_replace(array(" ", "\t"), '', $value_to_normalize);
32
+		if (preg_match('/^\d+$/', $value_to_normalize)) {
33
+			return intval($value_to_normalize);
34 34
 		} else {
35 35
 			//find if this input has a int validation strategy
36 36
 			//in which case, use its message
37 37
 			$validation_error_message = NULL;
38
-			foreach( $this->_input->get_validation_strategies() as $validation_strategy ){
39
-				if( $validation_strategy instanceof EE_Int_Validation_Strategy ){
38
+			foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
39
+				if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
40 40
 					$validation_error_message = $validation_strategy->get_validation_error_message();
41 41
 				}
42 42
 			}
43 43
 			//this really shouldn't ever happen because fields with a int normalization strategy
44 44
 			//should also have a int validation strategy, but in case it doesnt use the default
45
-			if( ! $validation_error_message ){
45
+			if ( ! $validation_error_message) {
46 46
 				$default_validation_strategy = new EE_Int_Validation_Strategy();
47 47
 				$validation_error_message = $default_validation_strategy->get_validation_error_message();
48 48
 			}
49
-			throw new EE_Validation_Error( $validation_error_message, 'numeric_only' );
49
+			throw new EE_Validation_Error($validation_error_message, 'numeric_only');
50 50
 		}
51 51
 	}
52 52
 
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 	 * @param int $normalized_value
56 56
 	 * @return string
57 57
 	 */
58
-	public function unnormalize( $normalized_value ) {
58
+	public function unnormalize($normalized_value) {
59 59
 	    if ($normalized_value === null || $normalized_value === '') {
60 60
 	        return '';
61
-        }elseif( empty( $normalized_value ) ){
61
+        }elseif (empty($normalized_value)) {
62 62
 			return '0';
63
-		}else{
63
+		} else {
64 64
 			return "$normalized_value";
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
 	public function unnormalize( $normalized_value ) {
59 59
 	    if ($normalized_value === null || $normalized_value === '') {
60 60
 	        return '';
61
-        }elseif( empty( $normalized_value ) ){
61
+        } elseif( empty( $normalized_value ) ){
62 62
 			return '0';
63
-		}else{
63
+		} else{
64 64
 			return "$normalized_value";
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -38,192 +38,192 @@
 block discarded – undo
38 38
  * @since            4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    /**
42
-     *    espresso_duplicate_plugin_error
43
-     *    displays if more than one version of EE is activated at the same time
44
-     */
45
-    function espresso_duplicate_plugin_error()
46
-    {
47
-        ?>
41
+	/**
42
+	 *    espresso_duplicate_plugin_error
43
+	 *    displays if more than one version of EE is activated at the same time
44
+	 */
45
+	function espresso_duplicate_plugin_error()
46
+	{
47
+		?>
48 48
         <div class="error">
49 49
             <p>
50 50
                 <?php echo esc_html__(
51
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
52
-                        'event_espresso'
53
-                ); ?>
51
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
52
+						'event_espresso'
53
+				); ?>
54 54
             </p>
55 55
         </div>
56 56
         <?php
57
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
58
-    }
57
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
58
+	}
59 59
 
60
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
60
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
61 61
 } else {
62
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
63
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
64
-        /**
65
-         * espresso_minimum_php_version_error
66
-         *
67
-         * @return void
68
-         */
69
-        function espresso_minimum_php_version_error()
70
-        {
71
-            ?>
62
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
63
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
64
+		/**
65
+		 * espresso_minimum_php_version_error
66
+		 *
67
+		 * @return void
68
+		 */
69
+		function espresso_minimum_php_version_error()
70
+		{
71
+			?>
72 72
             <div class="error">
73 73
                 <p>
74 74
                     <?php
75
-                    printf(
76
-                            esc_html__(
77
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
78
-                                    'event_espresso'
79
-                            ),
80
-                            EE_MIN_PHP_VER_REQUIRED,
81
-                            PHP_VERSION,
82
-                            '<br/>',
83
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
84
-                    );
85
-                    ?>
75
+					printf(
76
+							esc_html__(
77
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
78
+									'event_espresso'
79
+							),
80
+							EE_MIN_PHP_VER_REQUIRED,
81
+							PHP_VERSION,
82
+							'<br/>',
83
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
84
+					);
85
+					?>
86 86
                 </p>
87 87
             </div>
88 88
             <?php
89
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
90
-        }
89
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
90
+		}
91 91
 
92
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
92
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
93 93
 
94
-    } else {
94
+	} else {
95 95
 
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97 97
 
98
-        /**
99
-         * espresso_version
100
-         * Returns the plugin version
101
-         *
102
-         * @return string
103
-         */
104
-        function espresso_version()
105
-        {
106
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.37.rc.005');
107
-        }
98
+		/**
99
+		 * espresso_version
100
+		 * Returns the plugin version
101
+		 *
102
+		 * @return string
103
+		 */
104
+		function espresso_version()
105
+		{
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.37.rc.005');
107
+		}
108 108
 
109
-        /**
110
-         * espresso_plugin_activation
111
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
-         */
113
-        function espresso_plugin_activation()
114
-        {
115
-            update_option('ee_espresso_activation', true);
116
-        }
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
109
+		/**
110
+		 * espresso_plugin_activation
111
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
+		 */
113
+		function espresso_plugin_activation()
114
+		{
115
+			update_option('ee_espresso_activation', true);
116
+		}
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        /**
120
-         *    espresso_load_error_handling
121
-         *    this function loads EE's class for handling exceptions and errors
122
-         */
123
-        function espresso_load_error_handling()
124
-        {
125
-            static $error_handling_loaded = false;
126
-            if ($error_handling_loaded) {
127
-                return;
128
-            }
129
-            // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
-                \EEH_Debug_Tools::instance();
133
-            }
134
-            // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once(EE_CORE . 'EE_Error.core.php');
137
-            } else {
138
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
-            }
140
-            $error_handling_loaded = true;
141
-        }
119
+		/**
120
+		 *    espresso_load_error_handling
121
+		 *    this function loads EE's class for handling exceptions and errors
122
+		 */
123
+		function espresso_load_error_handling()
124
+		{
125
+			static $error_handling_loaded = false;
126
+			if ($error_handling_loaded) {
127
+				return;
128
+			}
129
+			// load debugging tools
130
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
+				\EEH_Debug_Tools::instance();
133
+			}
134
+			// load error handling
135
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
+				require_once(EE_CORE . 'EE_Error.core.php');
137
+			} else {
138
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
+			}
140
+			$error_handling_loaded = true;
141
+		}
142 142
 
143
-        /**
144
-         *    espresso_load_required
145
-         *    given a class name and path, this function will load that file or throw an exception
146
-         *
147
-         * @param    string $classname
148
-         * @param    string $full_path_to_file
149
-         * @throws    EE_Error
150
-         */
151
-        function espresso_load_required($classname, $full_path_to_file)
152
-        {
153
-            if (is_readable($full_path_to_file)) {
154
-                require_once($full_path_to_file);
155
-            } else {
156
-                throw new \EE_Error (
157
-                    sprintf(
158
-                        esc_html__(
159
-                            'The %s class file could not be located or is not readable due to file permissions.',
160
-                            'event_espresso'
161
-                        ),
162
-                        $classname
163
-                    )
164
-                );
165
-            }
166
-        }
143
+		/**
144
+		 *    espresso_load_required
145
+		 *    given a class name and path, this function will load that file or throw an exception
146
+		 *
147
+		 * @param    string $classname
148
+		 * @param    string $full_path_to_file
149
+		 * @throws    EE_Error
150
+		 */
151
+		function espresso_load_required($classname, $full_path_to_file)
152
+		{
153
+			if (is_readable($full_path_to_file)) {
154
+				require_once($full_path_to_file);
155
+			} else {
156
+				throw new \EE_Error (
157
+					sprintf(
158
+						esc_html__(
159
+							'The %s class file could not be located or is not readable due to file permissions.',
160
+							'event_espresso'
161
+						),
162
+						$classname
163
+					)
164
+				);
165
+			}
166
+		}
167 167
 
168
-        /**
169
-         * @since 4.9.27
170
-         * @throws \EE_Error
171
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
-         * @throws \OutOfBoundsException
179
-         */
180
-        function bootstrap_espresso()
181
-        {
182
-            try {
183
-                require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
184
-                espresso_load_error_handling();
185
-                espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
186
-                espresso_load_required('EEH_File', EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php');
187
-                espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
188
-                espresso_load_required('EEH_Array', EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php');
189
-                // instantiate and configure PSR4 autoloader
190
-                espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
191
-                espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
192
-                $AutoloaderInit = new \EE_Psr4AutoloaderInit();
193
-                $AutoloaderInit->initializeAutoloader();
194
-                espresso_load_required('EE_Request', EE_CORE . 'request_stack' . DS . 'EE_Request.core.php');
195
-                espresso_load_required('EE_Response', EE_CORE . 'request_stack' . DS . 'EE_Response.core.php');
196
-                espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
197
-                // bootstrap EE and the request stack
198
-                new EE_Bootstrap(
199
-                    new EE_Request($_GET, $_POST, $_COOKIE),
200
-                    new EE_Response()
201
-                );
202
-            } catch (Exception $e) {
203
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
204
-            }
205
-        }
168
+		/**
169
+		 * @since 4.9.27
170
+		 * @throws \EE_Error
171
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
175
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
+		 * @throws \OutOfBoundsException
179
+		 */
180
+		function bootstrap_espresso()
181
+		{
182
+			try {
183
+				require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
184
+				espresso_load_error_handling();
185
+				espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
186
+				espresso_load_required('EEH_File', EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php');
187
+				espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
188
+				espresso_load_required('EEH_Array', EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php');
189
+				// instantiate and configure PSR4 autoloader
190
+				espresso_load_required('Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php');
191
+				espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
192
+				$AutoloaderInit = new \EE_Psr4AutoloaderInit();
193
+				$AutoloaderInit->initializeAutoloader();
194
+				espresso_load_required('EE_Request', EE_CORE . 'request_stack' . DS . 'EE_Request.core.php');
195
+				espresso_load_required('EE_Response', EE_CORE . 'request_stack' . DS . 'EE_Response.core.php');
196
+				espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
197
+				// bootstrap EE and the request stack
198
+				new EE_Bootstrap(
199
+					new EE_Request($_GET, $_POST, $_COOKIE),
200
+					new EE_Response()
201
+				);
202
+			} catch (Exception $e) {
203
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
204
+			}
205
+		}
206 206
 
207
-        bootstrap_espresso();
207
+		bootstrap_espresso();
208 208
 
209
-    }
209
+	}
210 210
 }
211 211
 
212 212
 if ( ! function_exists('espresso_deactivate_plugin')) {
213
-    /**
214
-     *    deactivate_plugin
215
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
216
-     *
217
-     * @access public
218
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
219
-     * @return    void
220
-     */
221
-    function espresso_deactivate_plugin($plugin_basename = '')
222
-    {
223
-        if ( ! function_exists('deactivate_plugins')) {
224
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
225
-        }
226
-        unset($_GET['activate'], $_REQUEST['activate']);
227
-        deactivate_plugins($plugin_basename);
228
-    }
213
+	/**
214
+	 *    deactivate_plugin
215
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
216
+	 *
217
+	 * @access public
218
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
219
+	 * @return    void
220
+	 */
221
+	function espresso_deactivate_plugin($plugin_basename = '')
222
+	{
223
+		if ( ! function_exists('deactivate_plugins')) {
224
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
225
+		}
226
+		unset($_GET['activate'], $_REQUEST['activate']);
227
+		deactivate_plugins($plugin_basename);
228
+	}
229 229
 }
230 230
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Registry.core.php 2 patches
Indentation   +1361 added lines, -1361 removed lines patch added patch discarded remove patch
@@ -16,1397 +16,1397 @@
 block discarded – undo
16 16
 class EE_Registry
17 17
 {
18 18
 
19
-    /**
20
-     *    EE_Registry Object
21
-     *
22
-     * @var EE_Registry $_instance
23
-     * @access    private
24
-     */
25
-    private static $_instance = null;
26
-
27
-    /**
28
-     * @var EE_Dependency_Map $_dependency_map
29
-     * @access    protected
30
-     */
31
-    protected $_dependency_map = null;
32
-
33
-    /**
34
-     * @var array $_class_abbreviations
35
-     * @access    protected
36
-     */
37
-    protected $_class_abbreviations = array();
38
-
39
-    /**
40
-     * @access public
41
-     * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
-     */
43
-    public $BUS;
44
-
45
-    /**
46
-     *    EE_Cart Object
47
-     *
48
-     * @access    public
49
-     * @var    EE_Cart $CART
50
-     */
51
-    public $CART = null;
52
-
53
-    /**
54
-     *    EE_Config Object
55
-     *
56
-     * @access    public
57
-     * @var    EE_Config $CFG
58
-     */
59
-    public $CFG = null;
60
-
61
-    /**
62
-     * EE_Network_Config Object
63
-     *
64
-     * @access public
65
-     * @var EE_Network_Config $NET_CFG
66
-     */
67
-    public $NET_CFG = null;
68
-
69
-    /**
70
-     *    StdClass object for storing library classes in
71
-     *
72
-     * @public LIB
73
-     * @var StdClass $LIB
74
-     */
75
-    public $LIB = null;
76
-
77
-    /**
78
-     *    EE_Request_Handler Object
79
-     *
80
-     * @access    public
81
-     * @var    EE_Request_Handler $REQ
82
-     */
83
-    public $REQ = null;
84
-
85
-    /**
86
-     *    EE_Session Object
87
-     *
88
-     * @access    public
89
-     * @var    EE_Session $SSN
90
-     */
91
-    public $SSN = null;
92
-
93
-    /**
94
-     * holds the ee capabilities object.
95
-     *
96
-     * @since 4.5.0
97
-     * @var EE_Capabilities
98
-     */
99
-    public $CAP = null;
100
-
101
-    /**
102
-     * holds the EE_Message_Resource_Manager object.
103
-     *
104
-     * @since 4.9.0
105
-     * @var EE_Message_Resource_Manager
106
-     */
107
-    public $MRM = null;
108
-
109
-
110
-    /**
111
-     * Holds the Assets Registry instance
112
-     * @var Registry
113
-     */
114
-    public $AssetsRegistry = null;
115
-
116
-    /**
117
-     *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
-     *
119
-     * @access    public
120
-     * @var    EE_Addon[]
121
-     */
122
-    public $addons = null;
123
-
124
-    /**
125
-     *    $models
126
-     * @access    public
127
-     * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
-     */
129
-    public $models = array();
130
-
131
-    /**
132
-     *    $modules
133
-     * @access    public
134
-     * @var    EED_Module[] $modules
135
-     */
136
-    public $modules = null;
137
-
138
-    /**
139
-     *    $shortcodes
140
-     * @access    public
141
-     * @var    EES_Shortcode[] $shortcodes
142
-     */
143
-    public $shortcodes = null;
144
-
145
-    /**
146
-     *    $widgets
147
-     * @access    public
148
-     * @var    WP_Widget[] $widgets
149
-     */
150
-    public $widgets = null;
151
-
152
-    /**
153
-     * $non_abstract_db_models
154
-     * @access public
155
-     * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
-     * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
-     * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
-     * classnames (eg "EEM_Event")
159
-     */
160
-    public $non_abstract_db_models = array();
161
-
162
-
163
-    /**
164
-     *    $i18n_js_strings - internationalization for JS strings
165
-     *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
166
-     *    in js file:  var translatedString = eei18n.string_key;
167
-     *
168
-     * @access    public
169
-     * @var    array
170
-     */
171
-    public static $i18n_js_strings = array();
172
-
173
-
174
-    /**
175
-     *    $main_file - path to espresso.php
176
-     *
177
-     * @access    public
178
-     * @var    array
179
-     */
180
-    public $main_file;
181
-
182
-    /**
183
-     * array of ReflectionClass objects where the key is the class name
184
-     *
185
-     * @access    public
186
-     * @var ReflectionClass[]
187
-     */
188
-    public $_reflectors;
189
-
190
-    /**
191
-     * boolean flag to indicate whether or not to load/save dependencies from/to the cache
192
-     *
193
-     * @access    protected
194
-     * @var boolean $_cache_on
195
-     */
196
-    protected $_cache_on = true;
197
-
198
-
199
-
200
-    /**
201
-     * @singleton method used to instantiate class object
202
-     * @access    public
203
-     * @param  \EE_Dependency_Map $dependency_map
204
-     * @return \EE_Registry instance
205
-     */
206
-    public static function instance(\EE_Dependency_Map $dependency_map = null)
207
-    {
208
-        // check if class object is instantiated
209
-        if ( ! self::$_instance instanceof EE_Registry) {
210
-            self::$_instance = new EE_Registry($dependency_map);
211
-        }
212
-        return self::$_instance;
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     *protected constructor to prevent direct creation
219
-     *
220
-     * @Constructor
221
-     * @access protected
222
-     * @param  \EE_Dependency_Map $dependency_map
223
-     * @return \EE_Registry
224
-     */
225
-    protected function __construct(\EE_Dependency_Map $dependency_map)
226
-    {
227
-        $this->_dependency_map = $dependency_map;
228
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * initialize
235
-     */
236
-    public function initialize()
237
-    {
238
-        $this->_class_abbreviations = apply_filters(
239
-            'FHEE__EE_Registry____construct___class_abbreviations',
240
-            array(
241
-                'EE_Config'                                       => 'CFG',
242
-                'EE_Session'                                      => 'SSN',
243
-                'EE_Capabilities'                                 => 'CAP',
244
-                'EE_Cart'                                         => 'CART',
245
-                'EE_Network_Config'                               => 'NET_CFG',
246
-                'EE_Request_Handler'                              => 'REQ',
247
-                'EE_Message_Resource_Manager'                     => 'MRM',
248
-                'EventEspresso\core\services\commands\CommandBus' => 'BUS',
249
-            )
250
-        );
251
-        // class library
252
-        $this->LIB = new stdClass();
253
-        $this->addons = new stdClass();
254
-        $this->modules = new stdClass();
255
-        $this->shortcodes = new stdClass();
256
-        $this->widgets = new stdClass();
257
-        $this->load_core('Base', array(), true);
258
-        // add our request and response objects to the cache
259
-        $request_loader = $this->_dependency_map->class_loader('EE_Request');
260
-        $this->_set_cached_class(
261
-            $request_loader(),
262
-            'EE_Request'
263
-        );
264
-        $response_loader = $this->_dependency_map->class_loader('EE_Response');
265
-        $this->_set_cached_class(
266
-            $response_loader(),
267
-            'EE_Response'
268
-        );
269
-        add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
270
-    }
271
-
272
-
273
-
274
-    /**
275
-     *    init
276
-     *
277
-     * @access    public
278
-     * @return    void
279
-     */
280
-    public function init()
281
-    {
282
-        $this->AssetsRegistry = new Registry();
283
-        // Get current page protocol
284
-        $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
285
-        // Output admin-ajax.php URL with same protocol as current page
286
-        self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
287
-        self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
288
-    }
289
-
290
-
291
-
292
-    /**
293
-     * localize_i18n_js_strings
294
-     *
295
-     * @return string
296
-     */
297
-    public static function localize_i18n_js_strings()
298
-    {
299
-        $i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
300
-        foreach ($i18n_js_strings as $key => $value) {
301
-            if (is_scalar($value)) {
302
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
303
-            }
304
-        }
305
-        return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * @param mixed string | EED_Module $module
312
-     */
313
-    public function add_module($module)
314
-    {
315
-        if ($module instanceof EED_Module) {
316
-            $module_class = get_class($module);
317
-            $this->modules->{$module_class} = $module;
318
-        } else {
319
-            if ( ! class_exists('EE_Module_Request_Router', false)) {
320
-                $this->load_core('Module_Request_Router');
321
-            }
322
-            $this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
323
-        }
324
-    }
325
-
326
-
327
-
328
-    /**
329
-     * @param string $module_name
330
-     * @return mixed EED_Module | NULL
331
-     */
332
-    public function get_module($module_name = '')
333
-    {
334
-        return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     *    loads core classes - must be singletons
341
-     *
342
-     * @access    public
343
-     * @param string $class_name - simple class name ie: session
344
-     * @param mixed  $arguments
345
-     * @param bool   $load_only
346
-     * @return mixed
347
-     */
348
-    public function load_core($class_name, $arguments = array(), $load_only = false)
349
-    {
350
-        $core_paths = apply_filters(
351
-            'FHEE__EE_Registry__load_core__core_paths',
352
-            array(
353
-                EE_CORE,
354
-                EE_ADMIN,
355
-                EE_CPTS,
356
-                EE_CORE . 'data_migration_scripts' . DS,
357
-                EE_CORE . 'request_stack' . DS,
358
-                EE_CORE . 'middleware' . DS,
359
-            )
360
-        );
361
-        // retrieve instantiated class
362
-        return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     *    loads service classes
369
-     *
370
-     * @access    public
371
-     * @param string $class_name - simple class name ie: session
372
-     * @param mixed  $arguments
373
-     * @param bool   $load_only
374
-     * @return mixed
375
-     */
376
-    public function load_service($class_name, $arguments = array(), $load_only = false)
377
-    {
378
-        $service_paths = apply_filters(
379
-            'FHEE__EE_Registry__load_service__service_paths',
380
-            array(
381
-                EE_CORE . 'services' . DS,
382
-            )
383
-        );
384
-        // retrieve instantiated class
385
-        return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
386
-    }
387
-
388
-
389
-
390
-    /**
391
-     *    loads data_migration_scripts
392
-     *
393
-     * @access    public
394
-     * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
395
-     * @param mixed  $arguments
396
-     * @return EE_Data_Migration_Script_Base|mixed
397
-     */
398
-    public function load_dms($class_name, $arguments = array())
399
-    {
400
-        // retrieve instantiated class
401
-        return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     *    loads object creating classes - must be singletons
408
-     *
409
-     * @param string $class_name - simple class name ie: attendee
410
-     * @param mixed  $arguments  - an array of arguments to pass to the class
411
-     * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
412
-     * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
413
-     * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
414
-     * @return EE_Base_Class | bool
415
-     */
416
-    public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
-    {
418
-        $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
419
-            EE_CORE,
420
-            EE_CLASSES,
421
-            EE_BUSINESS,
422
-        ));
423
-        // retrieve instantiated class
424
-        return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     *    loads helper classes - must be singletons
431
-     *
432
-     * @param string $class_name - simple class name ie: price
433
-     * @param mixed  $arguments
434
-     * @param bool   $load_only
435
-     * @return EEH_Base | bool
436
-     */
437
-    public function load_helper($class_name, $arguments = array(), $load_only = true)
438
-    {
439
-        // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
440
-        $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
441
-        // retrieve instantiated class
442
-        return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     *    loads core classes - must be singletons
449
-     *
450
-     * @access    public
451
-     * @param string $class_name - simple class name ie: session
452
-     * @param mixed  $arguments
453
-     * @param bool   $load_only
454
-     * @param bool   $cache      whether to cache the object or not.
455
-     * @return mixed
456
-     */
457
-    public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
458
-    {
459
-        $paths = array(
460
-            EE_LIBRARIES,
461
-            EE_LIBRARIES . 'messages' . DS,
462
-            EE_LIBRARIES . 'shortcodes' . DS,
463
-            EE_LIBRARIES . 'qtips' . DS,
464
-            EE_LIBRARIES . 'payment_methods' . DS,
465
-            EE_LIBRARIES . 'messages' . DS . 'defaults' . DS,
466
-        );
467
-        // retrieve instantiated class
468
-        return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
469
-    }
470
-
471
-
472
-
473
-    /**
474
-     *    loads model classes - must be singletons
475
-     *
476
-     * @param string $class_name - simple class name ie: price
477
-     * @param mixed  $arguments
478
-     * @param bool   $load_only
479
-     * @return EEM_Base | bool
480
-     */
481
-    public function load_model($class_name, $arguments = array(), $load_only = false)
482
-    {
483
-        $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
484
-            EE_MODELS,
485
-            EE_CORE,
486
-        ));
487
-        // retrieve instantiated class
488
-        return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
489
-    }
490
-
491
-
492
-
493
-    /**
494
-     *    loads model classes - must be singletons
495
-     *
496
-     * @param string $class_name - simple class name ie: price
497
-     * @param mixed  $arguments
498
-     * @param bool   $load_only
499
-     * @return mixed | bool
500
-     */
501
-    public function load_model_class($class_name, $arguments = array(), $load_only = true)
502
-    {
503
-        $paths = array(
504
-            EE_MODELS . 'fields' . DS,
505
-            EE_MODELS . 'helpers' . DS,
506
-            EE_MODELS . 'relations' . DS,
507
-            EE_MODELS . 'strategies' . DS,
508
-        );
509
-        // retrieve instantiated class
510
-        return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
511
-    }
512
-
513
-
514
-
515
-    /**
516
-     * Determines if $model_name is the name of an actual EE model.
517
-     *
518
-     * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
519
-     * @return boolean
520
-     */
521
-    public function is_model_name($model_name)
522
-    {
523
-        return isset($this->models[$model_name]) ? true : false;
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    generic class loader
530
-     *
531
-     * @param string $path_to_file - directory path to file location, not including filename
532
-     * @param string $file_name    - file name  ie:  my_file.php, including extension
533
-     * @param string $type         - file type - core? class? helper? model?
534
-     * @param mixed  $arguments
535
-     * @param bool   $load_only
536
-     * @return mixed
537
-     */
538
-    public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
539
-    {
540
-        // retrieve instantiated class
541
-        return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
542
-    }
543
-
544
-
545
-
546
-    /**
547
-     *    load_addon
548
-     *
549
-     * @param string $path_to_file - directory path to file location, not including filename
550
-     * @param string $class_name   - full class name  ie:  My_Class
551
-     * @param string $type         - file type - core? class? helper? model?
552
-     * @param mixed  $arguments
553
-     * @param bool   $load_only
554
-     * @return EE_Addon
555
-     */
556
-    public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
557
-    {
558
-        // retrieve instantiated class
559
-        return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
560
-    }
561
-
562
-
563
-
564
-    /**
565
-     * instantiates, caches, and automatically resolves dependencies
566
-     * for classes that use a Fully Qualified Class Name.
567
-     * if the class is not capable of being loaded using PSR-4 autoloading,
568
-     * then you need to use one of the existing load_*() methods
569
-     * which can resolve the classname and filepath from the passed arguments
570
-     *
571
-     * @param bool|string $class_name   Fully Qualified Class Name
572
-     * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
573
-     * @param bool        $cache        whether to cache the instantiated object for reuse
574
-     * @param bool        $from_db      some classes are instantiated from the db
575
-     *                                  and thus call a different method to instantiate
576
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
577
-     * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
578
-     * @return mixed                    null = failure to load or instantiate class object.
579
-     *                                  object = class loaded and instantiated successfully.
580
-     *                                  bool = fail or success when $load_only is true
581
-     */
582
-    public function create(
583
-        $class_name = false,
584
-        $arguments = array(),
585
-        $cache = false,
586
-        $from_db = false,
587
-        $load_only = false,
588
-        $addon = false
589
-    ) {
590
-        $class_name = $this->_dependency_map->get_alias($class_name);
591
-        if ( ! class_exists($class_name)) {
592
-            // maybe the class is registered with a preceding \
593
-            $class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
594
-            // still doesn't exist ?
595
-            if ( ! class_exists($class_name)) {
596
-                return null;
597
-            }
598
-        }
599
-        // if we're only loading the class and it already exists, then let's just return true immediately
600
-        if ($load_only) {
601
-            return true;
602
-        }
603
-        $addon = $addon ? 'addon' : '';
604
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
605
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
606
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
607
-        if ($this->_cache_on && $cache && ! $load_only) {
608
-            // return object if it's already cached
609
-            $cached_class = $this->_get_cached_class($class_name, $addon);
610
-            if ($cached_class !== null) {
611
-                return $cached_class;
612
-            }
613
-        }
614
-        // instantiate the requested object
615
-        $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
616
-        if ($this->_cache_on && $cache) {
617
-            // save it for later... kinda like gum  { : $
618
-            $this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
619
-        }
620
-        $this->_cache_on = true;
621
-        return $class_obj;
622
-    }
623
-
624
-
625
-
626
-    /**
627
-     * instantiates, caches, and injects dependencies for classes
628
-     *
629
-     * @param array       $file_paths   an array of paths to folders to look in
630
-     * @param string      $class_prefix EE  or EEM or... ???
631
-     * @param bool|string $class_name   $class name
632
-     * @param string      $type         file type - core? class? helper? model?
633
-     * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
634
-     * @param bool        $from_db      some classes are instantiated from the db
635
-     *                                  and thus call a different method to instantiate
636
-     * @param bool        $cache        whether to cache the instantiated object for reuse
637
-     * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
638
-     * @return null|object|bool         null = failure to load or instantiate class object.
639
-     *                                  object = class loaded and instantiated successfully.
640
-     *                                  bool = fail or success when $load_only is true
641
-     */
642
-    protected function _load(
643
-        $file_paths = array(),
644
-        $class_prefix = 'EE_',
645
-        $class_name = false,
646
-        $type = 'class',
647
-        $arguments = array(),
648
-        $from_db = false,
649
-        $cache = true,
650
-        $load_only = false
651
-    ) {
652
-        // strip php file extension
653
-        $class_name = str_replace('.php', '', trim($class_name));
654
-        // does the class have a prefix ?
655
-        if ( ! empty($class_prefix) && $class_prefix != 'addon') {
656
-            // make sure $class_prefix is uppercase
657
-            $class_prefix = strtoupper(trim($class_prefix));
658
-            // add class prefix ONCE!!!
659
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
660
-        }
661
-        $class_name = $this->_dependency_map->get_alias($class_name);
662
-        $class_exists = class_exists($class_name, false);
663
-        // if we're only loading the class and it already exists, then let's just return true immediately
664
-        if ($load_only && $class_exists) {
665
-            return true;
666
-        }
667
-        // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
668
-        // $cache is controlled by individual calls to separate Registry loader methods like load_class()
669
-        // $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
670
-        if ($this->_cache_on && $cache && ! $load_only) {
671
-            // return object if it's already cached
672
-            $cached_class = $this->_get_cached_class($class_name, $class_prefix);
673
-            if ($cached_class !== null) {
674
-                return $cached_class;
675
-            }
676
-        }
677
-        // if the class doesn't already exist.. then we need to try and find the file and load it
678
-        if ( ! $class_exists) {
679
-            // get full path to file
680
-            $path = $this->_resolve_path($class_name, $type, $file_paths);
681
-            // load the file
682
-            $loaded = $this->_require_file($path, $class_name, $type, $file_paths);
683
-            // if loading failed, or we are only loading a file but NOT instantiating an object
684
-            if ( ! $loaded || $load_only) {
685
-                // return boolean if only loading, or null if an object was expected
686
-                return $load_only ? $loaded : null;
687
-            }
688
-        }
689
-        // instantiate the requested object
690
-        $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
691
-        if ($this->_cache_on && $cache) {
692
-            // save it for later... kinda like gum  { : $
693
-            $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
694
-        }
695
-        $this->_cache_on = true;
696
-        return $class_obj;
697
-    }
698
-
699
-
700
-
701
-    /**
702
-     * _get_cached_class
703
-     * attempts to find a cached version of the requested class
704
-     * by looking in the following places:
705
-     *        $this->{$class_abbreviation}            ie:    $this->CART
706
-     *        $this->{$class_name}                        ie:    $this->Some_Class
707
-     *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
708
-     *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
709
-     *
710
-     * @access protected
711
-     * @param string $class_name
712
-     * @param string $class_prefix
713
-     * @return mixed
714
-     */
715
-    protected function _get_cached_class($class_name, $class_prefix = '')
716
-    {
717
-        if (isset($this->_class_abbreviations[$class_name])) {
718
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
719
-        } else {
720
-            // have to specify something, but not anything that will conflict
721
-            $class_abbreviation = 'FANCY_BATMAN_PANTS';
722
-        }
723
-        // check if class has already been loaded, and return it if it has been
724
-        if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
725
-            return $this->{$class_abbreviation};
726
-        } else if (isset ($this->{$class_name})) {
727
-            return $this->{$class_name};
728
-        } else if (isset ($this->LIB->{$class_name})) {
729
-            return $this->LIB->{$class_name};
730
-        } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
731
-            return $this->addons->{$class_name};
732
-        }
733
-        return null;
734
-    }
735
-
736
-
737
-
738
-    /**
739
-     * _resolve_path
740
-     * attempts to find a full valid filepath for the requested class.
741
-     * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
742
-     * then returns that path if the target file has been found and is readable
743
-     *
744
-     * @access protected
745
-     * @param string $class_name
746
-     * @param string $type
747
-     * @param array  $file_paths
748
-     * @return string | bool
749
-     */
750
-    protected function _resolve_path($class_name, $type = '', $file_paths = array())
751
-    {
752
-        // make sure $file_paths is an array
753
-        $file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
754
-        // cycle thru paths
755
-        foreach ($file_paths as $key => $file_path) {
756
-            // convert all separators to proper DS, if no filepath, then use EE_CLASSES
757
-            $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
758
-            // prep file type
759
-            $type = ! empty($type) ? trim($type, '.') . '.' : '';
760
-            // build full file path
761
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
762
-            //does the file exist and can be read ?
763
-            if (is_readable($file_paths[$key])) {
764
-                return $file_paths[$key];
765
-            }
766
-        }
767
-        return false;
768
-    }
769
-
770
-
771
-
772
-    /**
773
-     * _require_file
774
-     * basically just performs a require_once()
775
-     * but with some error handling
776
-     *
777
-     * @access protected
778
-     * @param  string $path
779
-     * @param  string $class_name
780
-     * @param  string $type
781
-     * @param  array  $file_paths
782
-     * @return boolean
783
-     * @throws \EE_Error
784
-     */
785
-    protected function _require_file($path, $class_name, $type = '', $file_paths = array())
786
-    {
787
-        $this->resolve_legacy_class_parent($class_name);
788
-        // don't give up! you gotta...
789
-        try {
790
-            //does the file exist and can it be read ?
791
-            if ( ! $path) {
792
-                // so sorry, can't find the file
793
-                throw new EE_Error (
794
-                    sprintf(
795
-                        __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
796
-                        trim($type, '.'),
797
-                        $class_name,
798
-                        '<br />' . implode(',<br />', $file_paths)
799
-                    )
800
-                );
801
-            }
802
-            // get the file
803
-            require_once($path);
804
-            // if the class isn't already declared somewhere
805
-            if (class_exists($class_name, false) === false) {
806
-                // so sorry, not a class
807
-                throw new EE_Error(
808
-                    sprintf(
809
-                        __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
810
-                        $type,
811
-                        $path,
812
-                        $class_name
813
-                    )
814
-                );
815
-            }
816
-        } catch (EE_Error $e) {
817
-            $e->get_error();
818
-            return false;
819
-        }
820
-        return true;
821
-    }
822
-
823
-
824
-
825
-    /**
826
-     * Some of our legacy classes that extended a parent class would simply use a require() statement
827
-     * before their class declaration in order to ensure that the parent class was loaded.
828
-     * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
829
-     * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
830
-     *
831
-     * @param string $class_name
832
-     */
833
-    protected function resolve_legacy_class_parent($class_name = '')
834
-    {
835
-        try {
836
-            $legacy_parent_class_map = array(
837
-                'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php'
838
-            );
839
-            if(isset($legacy_parent_class_map[$class_name])) {
840
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[$class_name];
841
-            }
842
-        } catch (Exception $exception) {
843
-        }
844
-    }
845
-
846
-
847
-
848
-    /**
849
-     * _create_object
850
-     * Attempts to instantiate the requested class via any of the
851
-     * commonly used instantiation methods employed throughout EE.
852
-     * The priority for instantiation is as follows:
853
-     *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
854
-     *        - model objects via their 'new_instance_from_db' method
855
-     *        - model objects via their 'new_instance' method
856
-     *        - "singleton" classes" via their 'instance' method
857
-     *    - standard instantiable classes via their __constructor
858
-     * Prior to instantiation, if the classname exists in the dependency_map,
859
-     * then the constructor for the requested class will be examined to determine
860
-     * if any dependencies exist, and if they can be injected.
861
-     * If so, then those classes will be added to the array of arguments passed to the constructor
862
-     *
863
-     * @access protected
864
-     * @param string $class_name
865
-     * @param array  $arguments
866
-     * @param string $type
867
-     * @param bool   $from_db
868
-     * @return null | object
869
-     * @throws \EE_Error
870
-     */
871
-    protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
872
-    {
873
-        $class_obj = null;
874
-        $instantiation_mode = '0) none';
875
-        // don't give up! you gotta...
876
-        try {
877
-            // create reflection
878
-            $reflector = $this->get_ReflectionClass($class_name);
879
-            // make sure arguments are an array
880
-            $arguments = is_array($arguments) ? $arguments : array($arguments);
881
-            // and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
882
-            // else wrap it in an additional array so that it doesn't get split into multiple parameters
883
-            $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
884
-                ? $arguments
885
-                : array($arguments);
886
-            // attempt to inject dependencies ?
887
-            if ($this->_dependency_map->has($class_name)) {
888
-                $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
889
-            }
890
-            // instantiate the class if possible
891
-            if ($reflector->isAbstract()) {
892
-                // nothing to instantiate, loading file was enough
893
-                // does not throw an exception so $instantiation_mode is unused
894
-                // $instantiation_mode = "1) no constructor abstract class";
895
-                $class_obj = true;
896
-            } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
897
-                // no constructor = static methods only... nothing to instantiate, loading file was enough
898
-                $instantiation_mode = "2) no constructor but instantiable";
899
-                $class_obj = $reflector->newInstance();
900
-            } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
901
-                $instantiation_mode = "3) new_instance_from_db()";
902
-                $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
903
-            } else if (method_exists($class_name, 'new_instance')) {
904
-                $instantiation_mode = "4) new_instance()";
905
-                $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
906
-            } else if (method_exists($class_name, 'instance')) {
907
-                $instantiation_mode = "5) instance()";
908
-                $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
909
-            } else if ($reflector->isInstantiable()) {
910
-                $instantiation_mode = "6) constructor";
911
-                $class_obj = $reflector->newInstanceArgs($arguments);
912
-            } else {
913
-                // heh ? something's not right !
914
-                throw new EE_Error(
915
-                    sprintf(
916
-                        __('The %s file %s could not be instantiated.', 'event_espresso'),
917
-                        $type,
918
-                        $class_name
919
-                    )
920
-                );
921
-            }
922
-        } catch (Exception $e) {
923
-            if ( ! $e instanceof EE_Error) {
924
-                $e = new EE_Error(
925
-                    sprintf(
926
-                        __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
927
-                        $class_name,
928
-                        '<br />',
929
-                        $e->getMessage(),
930
-                        $instantiation_mode
931
-                    )
932
-                );
933
-            }
934
-            $e->get_error();
935
-        }
936
-        return $class_obj;
937
-    }
938
-
939
-
940
-
941
-    /**
942
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
943
-     * @param array $array
944
-     * @return bool
945
-     */
946
-    protected function _array_is_numerically_and_sequentially_indexed(array $array)
947
-    {
948
-        return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
949
-    }
950
-
951
-
952
-
953
-    /**
954
-     * getReflectionClass
955
-     * checks if a ReflectionClass object has already been generated for a class
956
-     * and returns that instead of creating a new one
957
-     *
958
-     * @access public
959
-     * @param string $class_name
960
-     * @return ReflectionClass
961
-     */
962
-    public function get_ReflectionClass($class_name)
963
-    {
964
-        if (
965
-            ! isset($this->_reflectors[$class_name])
966
-            || ! $this->_reflectors[$class_name] instanceof ReflectionClass
967
-        ) {
968
-            $this->_reflectors[$class_name] = new ReflectionClass($class_name);
969
-        }
970
-        return $this->_reflectors[$class_name];
971
-    }
972
-
973
-
974
-
975
-    /**
976
-     * _resolve_dependencies
977
-     * examines the constructor for the requested class to determine
978
-     * if any dependencies exist, and if they can be injected.
979
-     * If so, then those classes will be added to the array of arguments passed to the constructor
980
-     * PLZ NOTE: this is achieved by type hinting the constructor params
981
-     * For example:
982
-     *        if attempting to load a class "Foo" with the following constructor:
983
-     *        __construct( Bar $bar_class, Fighter $grohl_class )
984
-     *        then $bar_class and $grohl_class will be added to the $arguments array,
985
-     *        but only IF they are NOT already present in the incoming arguments array,
986
-     *        and the correct classes can be loaded
987
-     *
988
-     * @access protected
989
-     * @param ReflectionClass $reflector
990
-     * @param string          $class_name
991
-     * @param array           $arguments
992
-     * @return array
993
-     * @throws \ReflectionException
994
-     */
995
-    protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
996
-    {
997
-        // let's examine the constructor
998
-        $constructor = $reflector->getConstructor();
999
-        // whu? huh? nothing?
1000
-        if ( ! $constructor) {
1001
-            return $arguments;
1002
-        }
1003
-        // get constructor parameters
1004
-        $params = $constructor->getParameters();
1005
-        // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1006
-        $argument_keys = array_keys($arguments);
1007
-        // now loop thru all of the constructors expected parameters
1008
-        foreach ($params as $index => $param) {
1009
-            // is this a dependency for a specific class ?
1010
-            $param_class = $param->getClass() ? $param->getClass()->name : null;
1011
-            if (
1012
-                // param is not even a class
1013
-                empty($param_class)
1014
-                // and something already exists in the incoming arguments for this param
1015
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1016
-            ) {
1017
-                // so let's skip this argument and move on to the next
1018
-                continue;
1019
-            } else if (
1020
-                // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1021
-                ! empty($param_class)
1022
-                && isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1023
-                && $arguments[$argument_keys[$index]] instanceof $param_class
1024
-            ) {
1025
-                // skip this argument and move on to the next
1026
-                continue;
1027
-            } else if (
1028
-                // parameter is type hinted as a class, and should be injected
1029
-                ! empty($param_class)
1030
-                && $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1031
-            ) {
1032
-                $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1033
-            } else {
1034
-                try {
1035
-                    $arguments[$index] = $param->getDefaultValue();
1036
-                } catch (ReflectionException $e) {
1037
-                    throw new ReflectionException(
1038
-                        sprintf(
1039
-                            __('%1$s for parameter "$%2$s"', 'event_espresso'),
1040
-                            $e->getMessage(),
1041
-                            $param->getName()
1042
-                        )
1043
-                    );
1044
-                }
1045
-            }
1046
-        }
1047
-        return $arguments;
1048
-    }
1049
-
1050
-
1051
-
1052
-    /**
1053
-     * @access protected
1054
-     * @param string $class_name
1055
-     * @param string $param_class
1056
-     * @param array  $arguments
1057
-     * @param mixed  $index
1058
-     * @return array
1059
-     */
1060
-    protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1061
-    {
1062
-        $dependency = null;
1063
-        // should dependency be loaded from cache ?
1064
-        $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1065
-                    !== EE_Dependency_Map::load_new_object
1066
-            ? true
1067
-            : false;
1068
-        // we might have a dependency...
1069
-        // let's MAYBE try and find it in our cache if that's what's been requested
1070
-        $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1071
-        // and grab it if it exists
1072
-        if ($cached_class instanceof $param_class) {
1073
-            $dependency = $cached_class;
1074
-        } else if ($param_class != $class_name) {
1075
-            // obtain the loader method from the dependency map
1076
-            $loader = $this->_dependency_map->class_loader($param_class);
1077
-            // is loader a custom closure ?
1078
-            if ($loader instanceof Closure) {
1079
-                $dependency = $loader();
1080
-            } else {
1081
-                // set the cache on property for the recursive loading call
1082
-                $this->_cache_on = $cache_on;
1083
-                // if not, then let's try and load it via the registry
1084
-                if (method_exists($this, $loader)) {
1085
-                    $dependency = $this->{$loader}($param_class);
1086
-                } else {
1087
-                    $dependency = $this->create($param_class, array(), $cache_on);
1088
-                }
1089
-            }
1090
-        }
1091
-        // did we successfully find the correct dependency ?
1092
-        if ($dependency instanceof $param_class) {
1093
-            // then let's inject it into the incoming array of arguments at the correct location
1094
-            if (isset($argument_keys[$index])) {
1095
-                $arguments[$argument_keys[$index]] = $dependency;
1096
-            } else {
1097
-                $arguments[$index] = $dependency;
1098
-            }
1099
-        }
1100
-        return $arguments;
1101
-    }
1102
-
1103
-
1104
-
1105
-    /**
1106
-     * _set_cached_class
1107
-     * attempts to cache the instantiated class locally
1108
-     * in one of the following places, in the following order:
1109
-     *        $this->{class_abbreviation}   ie:    $this->CART
1110
-     *        $this->{$class_name}          ie:    $this->Some_Class
1111
-     *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1112
-     *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1113
-     *
1114
-     * @access protected
1115
-     * @param object $class_obj
1116
-     * @param string $class_name
1117
-     * @param string $class_prefix
1118
-     * @param bool   $from_db
1119
-     * @return void
1120
-     */
1121
-    protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1122
-    {
1123
-        if (empty($class_obj)) {
1124
-            return;
1125
-        }
1126
-        // return newly instantiated class
1127
-        if (isset($this->_class_abbreviations[$class_name])) {
1128
-            $class_abbreviation = $this->_class_abbreviations[$class_name];
1129
-            $this->{$class_abbreviation} = $class_obj;
1130
-        } else if (property_exists($this, $class_name)) {
1131
-            $this->{$class_name} = $class_obj;
1132
-        } else if ($class_prefix == 'addon') {
1133
-            $this->addons->{$class_name} = $class_obj;
1134
-        } else if ( ! $from_db) {
1135
-            $this->LIB->{$class_name} = $class_obj;
1136
-        }
1137
-    }
1138
-
1139
-
1140
-
1141
-    /**
1142
-     * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1143
-     *
1144
-     * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1145
-     *                          in the EE_Dependency_Map::$_class_loaders array,
1146
-     *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1147
-     * @param array  $arguments
1148
-     * @return object
1149
-     */
1150
-    public static function factory($classname, $arguments = array())
1151
-    {
1152
-        $loader = self::instance()->_dependency_map->class_loader($classname);
1153
-        if ($loader instanceof Closure) {
1154
-            return $loader($arguments);
1155
-        } else if (method_exists(EE_Registry::instance(), $loader)) {
1156
-            return EE_Registry::instance()->{$loader}($classname, $arguments);
1157
-        }
1158
-        return null;
1159
-    }
1160
-
1161
-
1162
-
1163
-    /**
1164
-     * Gets the addon by its name/slug (not classname. For that, just
1165
-     * use the classname as the property name on EE_Config::instance()->addons)
1166
-     *
1167
-     * @param string $name
1168
-     * @return EE_Addon
1169
-     */
1170
-    public function get_addon_by_name($name)
1171
-    {
1172
-        foreach ($this->addons as $addon) {
1173
-            if ($addon->name() == $name) {
1174
-                return $addon;
1175
-            }
1176
-        }
1177
-        return null;
1178
-    }
1179
-
1180
-
1181
-
1182
-    /**
1183
-     * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1184
-     * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1185
-     *
1186
-     * @return EE_Addon[] where the KEYS are the addon's name()
1187
-     */
1188
-    public function get_addons_by_name()
1189
-    {
1190
-        $addons = array();
1191
-        foreach ($this->addons as $addon) {
1192
-            $addons[$addon->name()] = $addon;
1193
-        }
1194
-        return $addons;
1195
-    }
1196
-
1197
-
1198
-
1199
-    /**
1200
-     * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1201
-     * a stale copy of it around
1202
-     *
1203
-     * @param string $model_name
1204
-     * @return \EEM_Base
1205
-     * @throws \EE_Error
1206
-     */
1207
-    public function reset_model($model_name)
1208
-    {
1209
-        $model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1210
-        if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1211
-            return null;
1212
-        }
1213
-        //get that model reset it and make sure we nuke the old reference to it
1214
-        if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1215
-            $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1216
-        } else {
1217
-            throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1218
-        }
1219
-        return $this->LIB->{$model_class_name};
1220
-    }
1221
-
1222
-
1223
-
1224
-    /**
1225
-     * Resets the registry.
1226
-     * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1227
-     * is used in a multisite install.  Here is a list of things that are NOT reset.
1228
-     * - $_dependency_map
1229
-     * - $_class_abbreviations
1230
-     * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1231
-     * - $REQ:  Still on the same request so no need to change.
1232
-     * - $CAP: There is no site specific state in the EE_Capability class.
1233
-     * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1234
-     *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1235
-     * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1236
-     *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1237
-     *             switch or on the restore.
1238
-     * - $modules
1239
-     * - $shortcodes
1240
-     * - $widgets
1241
-     *
1242
-     * @param boolean $hard             whether to reset data in the database too, or just refresh
1243
-     *                                  the Registry to its state at the beginning of the request
1244
-     * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1245
-     *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1246
-     *                                  currently reinstantiate the singletons at the moment)
1247
-     * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1248
-     *                                  code instead can just change the model context to a different blog id if necessary
1249
-     * @return EE_Registry
1250
-     */
1251
-    public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1252
-    {
1253
-        $instance = self::instance();
1254
-        EEH_Activation::reset();
1255
-        //properties that get reset
1256
-        $instance->_cache_on = true;
1257
-        $instance->CFG = EE_Config::reset($hard, $reinstantiate);
1258
-        $instance->CART = null;
1259
-        $instance->MRM = null;
1260
-        $instance->AssetsRegistry = new Registry();
1261
-        //messages reset
1262
-        EED_Messages::reset();
1263
-        if ($reset_models) {
1264
-            foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1265
-                $instance->reset_model($model_name);
1266
-            }
1267
-        }
1268
-        $instance->LIB = new stdClass();
1269
-        return $instance;
1270
-    }
1271
-
1272
-
1273
-
1274
-    /**
1275
-     * @override magic methods
1276
-     * @return void
1277
-     */
1278
-    final function __destruct()
1279
-    {
1280
-    }
1281
-
1282
-
1283
-
1284
-    /**
1285
-     * @param $a
1286
-     * @param $b
1287
-     */
1288
-    final function __call($a, $b)
1289
-    {
1290
-    }
1291
-
1292
-
1293
-
1294
-    /**
1295
-     * @param $a
1296
-     */
1297
-    final function __get($a)
1298
-    {
1299
-    }
1300
-
1301
-
1302
-
1303
-    /**
1304
-     * @param $a
1305
-     * @param $b
1306
-     */
1307
-    final function __set($a, $b)
1308
-    {
1309
-    }
1310
-
1311
-
1312
-
1313
-    /**
1314
-     * @param $a
1315
-     */
1316
-    final function __isset($a)
1317
-    {
1318
-    }
19
+	/**
20
+	 *    EE_Registry Object
21
+	 *
22
+	 * @var EE_Registry $_instance
23
+	 * @access    private
24
+	 */
25
+	private static $_instance = null;
26
+
27
+	/**
28
+	 * @var EE_Dependency_Map $_dependency_map
29
+	 * @access    protected
30
+	 */
31
+	protected $_dependency_map = null;
32
+
33
+	/**
34
+	 * @var array $_class_abbreviations
35
+	 * @access    protected
36
+	 */
37
+	protected $_class_abbreviations = array();
38
+
39
+	/**
40
+	 * @access public
41
+	 * @var \EventEspresso\core\services\commands\CommandBusInterface $BUS
42
+	 */
43
+	public $BUS;
44
+
45
+	/**
46
+	 *    EE_Cart Object
47
+	 *
48
+	 * @access    public
49
+	 * @var    EE_Cart $CART
50
+	 */
51
+	public $CART = null;
52
+
53
+	/**
54
+	 *    EE_Config Object
55
+	 *
56
+	 * @access    public
57
+	 * @var    EE_Config $CFG
58
+	 */
59
+	public $CFG = null;
60
+
61
+	/**
62
+	 * EE_Network_Config Object
63
+	 *
64
+	 * @access public
65
+	 * @var EE_Network_Config $NET_CFG
66
+	 */
67
+	public $NET_CFG = null;
68
+
69
+	/**
70
+	 *    StdClass object for storing library classes in
71
+	 *
72
+	 * @public LIB
73
+	 * @var StdClass $LIB
74
+	 */
75
+	public $LIB = null;
76
+
77
+	/**
78
+	 *    EE_Request_Handler Object
79
+	 *
80
+	 * @access    public
81
+	 * @var    EE_Request_Handler $REQ
82
+	 */
83
+	public $REQ = null;
84
+
85
+	/**
86
+	 *    EE_Session Object
87
+	 *
88
+	 * @access    public
89
+	 * @var    EE_Session $SSN
90
+	 */
91
+	public $SSN = null;
92
+
93
+	/**
94
+	 * holds the ee capabilities object.
95
+	 *
96
+	 * @since 4.5.0
97
+	 * @var EE_Capabilities
98
+	 */
99
+	public $CAP = null;
100
+
101
+	/**
102
+	 * holds the EE_Message_Resource_Manager object.
103
+	 *
104
+	 * @since 4.9.0
105
+	 * @var EE_Message_Resource_Manager
106
+	 */
107
+	public $MRM = null;
108
+
109
+
110
+	/**
111
+	 * Holds the Assets Registry instance
112
+	 * @var Registry
113
+	 */
114
+	public $AssetsRegistry = null;
115
+
116
+	/**
117
+	 *    $addons - StdClass object for holding addons which have registered themselves to work with EE core
118
+	 *
119
+	 * @access    public
120
+	 * @var    EE_Addon[]
121
+	 */
122
+	public $addons = null;
123
+
124
+	/**
125
+	 *    $models
126
+	 * @access    public
127
+	 * @var    EEM_Base[] $models keys are 'short names' (eg Event), values are class names (eg 'EEM_Event')
128
+	 */
129
+	public $models = array();
130
+
131
+	/**
132
+	 *    $modules
133
+	 * @access    public
134
+	 * @var    EED_Module[] $modules
135
+	 */
136
+	public $modules = null;
137
+
138
+	/**
139
+	 *    $shortcodes
140
+	 * @access    public
141
+	 * @var    EES_Shortcode[] $shortcodes
142
+	 */
143
+	public $shortcodes = null;
144
+
145
+	/**
146
+	 *    $widgets
147
+	 * @access    public
148
+	 * @var    WP_Widget[] $widgets
149
+	 */
150
+	public $widgets = null;
151
+
152
+	/**
153
+	 * $non_abstract_db_models
154
+	 * @access public
155
+	 * @var array this is an array of all implemented model names (i.e. not the parent abstract models, or models
156
+	 * which don't actually fetch items from the DB in the normal way (ie, are not children of EEM_Base)).
157
+	 * Keys are model "short names" (eg "Event") as used in model relations, and values are
158
+	 * classnames (eg "EEM_Event")
159
+	 */
160
+	public $non_abstract_db_models = array();
161
+
162
+
163
+	/**
164
+	 *    $i18n_js_strings - internationalization for JS strings
165
+	 *    usage:   EE_Registry::i18n_js_strings['string_key'] = __( 'string to translate.', 'event_espresso' );
166
+	 *    in js file:  var translatedString = eei18n.string_key;
167
+	 *
168
+	 * @access    public
169
+	 * @var    array
170
+	 */
171
+	public static $i18n_js_strings = array();
172
+
173
+
174
+	/**
175
+	 *    $main_file - path to espresso.php
176
+	 *
177
+	 * @access    public
178
+	 * @var    array
179
+	 */
180
+	public $main_file;
181
+
182
+	/**
183
+	 * array of ReflectionClass objects where the key is the class name
184
+	 *
185
+	 * @access    public
186
+	 * @var ReflectionClass[]
187
+	 */
188
+	public $_reflectors;
189
+
190
+	/**
191
+	 * boolean flag to indicate whether or not to load/save dependencies from/to the cache
192
+	 *
193
+	 * @access    protected
194
+	 * @var boolean $_cache_on
195
+	 */
196
+	protected $_cache_on = true;
197
+
198
+
199
+
200
+	/**
201
+	 * @singleton method used to instantiate class object
202
+	 * @access    public
203
+	 * @param  \EE_Dependency_Map $dependency_map
204
+	 * @return \EE_Registry instance
205
+	 */
206
+	public static function instance(\EE_Dependency_Map $dependency_map = null)
207
+	{
208
+		// check if class object is instantiated
209
+		if ( ! self::$_instance instanceof EE_Registry) {
210
+			self::$_instance = new EE_Registry($dependency_map);
211
+		}
212
+		return self::$_instance;
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 *protected constructor to prevent direct creation
219
+	 *
220
+	 * @Constructor
221
+	 * @access protected
222
+	 * @param  \EE_Dependency_Map $dependency_map
223
+	 * @return \EE_Registry
224
+	 */
225
+	protected function __construct(\EE_Dependency_Map $dependency_map)
226
+	{
227
+		$this->_dependency_map = $dependency_map;
228
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * initialize
235
+	 */
236
+	public function initialize()
237
+	{
238
+		$this->_class_abbreviations = apply_filters(
239
+			'FHEE__EE_Registry____construct___class_abbreviations',
240
+			array(
241
+				'EE_Config'                                       => 'CFG',
242
+				'EE_Session'                                      => 'SSN',
243
+				'EE_Capabilities'                                 => 'CAP',
244
+				'EE_Cart'                                         => 'CART',
245
+				'EE_Network_Config'                               => 'NET_CFG',
246
+				'EE_Request_Handler'                              => 'REQ',
247
+				'EE_Message_Resource_Manager'                     => 'MRM',
248
+				'EventEspresso\core\services\commands\CommandBus' => 'BUS',
249
+			)
250
+		);
251
+		// class library
252
+		$this->LIB = new stdClass();
253
+		$this->addons = new stdClass();
254
+		$this->modules = new stdClass();
255
+		$this->shortcodes = new stdClass();
256
+		$this->widgets = new stdClass();
257
+		$this->load_core('Base', array(), true);
258
+		// add our request and response objects to the cache
259
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
260
+		$this->_set_cached_class(
261
+			$request_loader(),
262
+			'EE_Request'
263
+		);
264
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
265
+		$this->_set_cached_class(
266
+			$response_loader(),
267
+			'EE_Response'
268
+		);
269
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
270
+	}
271
+
272
+
273
+
274
+	/**
275
+	 *    init
276
+	 *
277
+	 * @access    public
278
+	 * @return    void
279
+	 */
280
+	public function init()
281
+	{
282
+		$this->AssetsRegistry = new Registry();
283
+		// Get current page protocol
284
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
285
+		// Output admin-ajax.php URL with same protocol as current page
286
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
287
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
288
+	}
289
+
290
+
291
+
292
+	/**
293
+	 * localize_i18n_js_strings
294
+	 *
295
+	 * @return string
296
+	 */
297
+	public static function localize_i18n_js_strings()
298
+	{
299
+		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
300
+		foreach ($i18n_js_strings as $key => $value) {
301
+			if (is_scalar($value)) {
302
+				$i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
303
+			}
304
+		}
305
+		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * @param mixed string | EED_Module $module
312
+	 */
313
+	public function add_module($module)
314
+	{
315
+		if ($module instanceof EED_Module) {
316
+			$module_class = get_class($module);
317
+			$this->modules->{$module_class} = $module;
318
+		} else {
319
+			if ( ! class_exists('EE_Module_Request_Router', false)) {
320
+				$this->load_core('Module_Request_Router');
321
+			}
322
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
323
+		}
324
+	}
325
+
326
+
327
+
328
+	/**
329
+	 * @param string $module_name
330
+	 * @return mixed EED_Module | NULL
331
+	 */
332
+	public function get_module($module_name = '')
333
+	{
334
+		return isset($this->modules->{$module_name}) ? $this->modules->{$module_name} : null;
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 *    loads core classes - must be singletons
341
+	 *
342
+	 * @access    public
343
+	 * @param string $class_name - simple class name ie: session
344
+	 * @param mixed  $arguments
345
+	 * @param bool   $load_only
346
+	 * @return mixed
347
+	 */
348
+	public function load_core($class_name, $arguments = array(), $load_only = false)
349
+	{
350
+		$core_paths = apply_filters(
351
+			'FHEE__EE_Registry__load_core__core_paths',
352
+			array(
353
+				EE_CORE,
354
+				EE_ADMIN,
355
+				EE_CPTS,
356
+				EE_CORE . 'data_migration_scripts' . DS,
357
+				EE_CORE . 'request_stack' . DS,
358
+				EE_CORE . 'middleware' . DS,
359
+			)
360
+		);
361
+		// retrieve instantiated class
362
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 *    loads service classes
369
+	 *
370
+	 * @access    public
371
+	 * @param string $class_name - simple class name ie: session
372
+	 * @param mixed  $arguments
373
+	 * @param bool   $load_only
374
+	 * @return mixed
375
+	 */
376
+	public function load_service($class_name, $arguments = array(), $load_only = false)
377
+	{
378
+		$service_paths = apply_filters(
379
+			'FHEE__EE_Registry__load_service__service_paths',
380
+			array(
381
+				EE_CORE . 'services' . DS,
382
+			)
383
+		);
384
+		// retrieve instantiated class
385
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
386
+	}
387
+
388
+
389
+
390
+	/**
391
+	 *    loads data_migration_scripts
392
+	 *
393
+	 * @access    public
394
+	 * @param string $class_name - class name for the DMS ie: EE_DMS_Core_4_2_0
395
+	 * @param mixed  $arguments
396
+	 * @return EE_Data_Migration_Script_Base|mixed
397
+	 */
398
+	public function load_dms($class_name, $arguments = array())
399
+	{
400
+		// retrieve instantiated class
401
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 *    loads object creating classes - must be singletons
408
+	 *
409
+	 * @param string $class_name - simple class name ie: attendee
410
+	 * @param mixed  $arguments  - an array of arguments to pass to the class
411
+	 * @param bool   $from_db    - some classes are instantiated from the db and thus call a different method to instantiate
412
+	 * @param bool   $cache      if you don't want the class to be stored in the internal cache (non-persistent) then set this to FALSE (ie. when instantiating model objects from client in a loop)
413
+	 * @param bool   $load_only  whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
414
+	 * @return EE_Base_Class | bool
415
+	 */
416
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false)
417
+	{
418
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
419
+			EE_CORE,
420
+			EE_CLASSES,
421
+			EE_BUSINESS,
422
+		));
423
+		// retrieve instantiated class
424
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 *    loads helper classes - must be singletons
431
+	 *
432
+	 * @param string $class_name - simple class name ie: price
433
+	 * @param mixed  $arguments
434
+	 * @param bool   $load_only
435
+	 * @return EEH_Base | bool
436
+	 */
437
+	public function load_helper($class_name, $arguments = array(), $load_only = true)
438
+	{
439
+		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
440
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
441
+		// retrieve instantiated class
442
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 *    loads core classes - must be singletons
449
+	 *
450
+	 * @access    public
451
+	 * @param string $class_name - simple class name ie: session
452
+	 * @param mixed  $arguments
453
+	 * @param bool   $load_only
454
+	 * @param bool   $cache      whether to cache the object or not.
455
+	 * @return mixed
456
+	 */
457
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true)
458
+	{
459
+		$paths = array(
460
+			EE_LIBRARIES,
461
+			EE_LIBRARIES . 'messages' . DS,
462
+			EE_LIBRARIES . 'shortcodes' . DS,
463
+			EE_LIBRARIES . 'qtips' . DS,
464
+			EE_LIBRARIES . 'payment_methods' . DS,
465
+			EE_LIBRARIES . 'messages' . DS . 'defaults' . DS,
466
+		);
467
+		// retrieve instantiated class
468
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
469
+	}
470
+
471
+
472
+
473
+	/**
474
+	 *    loads model classes - must be singletons
475
+	 *
476
+	 * @param string $class_name - simple class name ie: price
477
+	 * @param mixed  $arguments
478
+	 * @param bool   $load_only
479
+	 * @return EEM_Base | bool
480
+	 */
481
+	public function load_model($class_name, $arguments = array(), $load_only = false)
482
+	{
483
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
484
+			EE_MODELS,
485
+			EE_CORE,
486
+		));
487
+		// retrieve instantiated class
488
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
489
+	}
490
+
491
+
492
+
493
+	/**
494
+	 *    loads model classes - must be singletons
495
+	 *
496
+	 * @param string $class_name - simple class name ie: price
497
+	 * @param mixed  $arguments
498
+	 * @param bool   $load_only
499
+	 * @return mixed | bool
500
+	 */
501
+	public function load_model_class($class_name, $arguments = array(), $load_only = true)
502
+	{
503
+		$paths = array(
504
+			EE_MODELS . 'fields' . DS,
505
+			EE_MODELS . 'helpers' . DS,
506
+			EE_MODELS . 'relations' . DS,
507
+			EE_MODELS . 'strategies' . DS,
508
+		);
509
+		// retrieve instantiated class
510
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
511
+	}
512
+
513
+
514
+
515
+	/**
516
+	 * Determines if $model_name is the name of an actual EE model.
517
+	 *
518
+	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
519
+	 * @return boolean
520
+	 */
521
+	public function is_model_name($model_name)
522
+	{
523
+		return isset($this->models[$model_name]) ? true : false;
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    generic class loader
530
+	 *
531
+	 * @param string $path_to_file - directory path to file location, not including filename
532
+	 * @param string $file_name    - file name  ie:  my_file.php, including extension
533
+	 * @param string $type         - file type - core? class? helper? model?
534
+	 * @param mixed  $arguments
535
+	 * @param bool   $load_only
536
+	 * @return mixed
537
+	 */
538
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true)
539
+	{
540
+		// retrieve instantiated class
541
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
542
+	}
543
+
544
+
545
+
546
+	/**
547
+	 *    load_addon
548
+	 *
549
+	 * @param string $path_to_file - directory path to file location, not including filename
550
+	 * @param string $class_name   - full class name  ie:  My_Class
551
+	 * @param string $type         - file type - core? class? helper? model?
552
+	 * @param mixed  $arguments
553
+	 * @param bool   $load_only
554
+	 * @return EE_Addon
555
+	 */
556
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false)
557
+	{
558
+		// retrieve instantiated class
559
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
560
+	}
561
+
562
+
563
+
564
+	/**
565
+	 * instantiates, caches, and automatically resolves dependencies
566
+	 * for classes that use a Fully Qualified Class Name.
567
+	 * if the class is not capable of being loaded using PSR-4 autoloading,
568
+	 * then you need to use one of the existing load_*() methods
569
+	 * which can resolve the classname and filepath from the passed arguments
570
+	 *
571
+	 * @param bool|string $class_name   Fully Qualified Class Name
572
+	 * @param array       $arguments    an argument, or array of arguments to pass to the class upon instantiation
573
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
574
+	 * @param bool        $from_db      some classes are instantiated from the db
575
+	 *                                  and thus call a different method to instantiate
576
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
577
+	 * @param bool|string $addon        if true, will cache the object in the EE_Registry->$addons array
578
+	 * @return mixed                    null = failure to load or instantiate class object.
579
+	 *                                  object = class loaded and instantiated successfully.
580
+	 *                                  bool = fail or success when $load_only is true
581
+	 */
582
+	public function create(
583
+		$class_name = false,
584
+		$arguments = array(),
585
+		$cache = false,
586
+		$from_db = false,
587
+		$load_only = false,
588
+		$addon = false
589
+	) {
590
+		$class_name = $this->_dependency_map->get_alias($class_name);
591
+		if ( ! class_exists($class_name)) {
592
+			// maybe the class is registered with a preceding \
593
+			$class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
594
+			// still doesn't exist ?
595
+			if ( ! class_exists($class_name)) {
596
+				return null;
597
+			}
598
+		}
599
+		// if we're only loading the class and it already exists, then let's just return true immediately
600
+		if ($load_only) {
601
+			return true;
602
+		}
603
+		$addon = $addon ? 'addon' : '';
604
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
605
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
606
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
607
+		if ($this->_cache_on && $cache && ! $load_only) {
608
+			// return object if it's already cached
609
+			$cached_class = $this->_get_cached_class($class_name, $addon);
610
+			if ($cached_class !== null) {
611
+				return $cached_class;
612
+			}
613
+		}
614
+		// instantiate the requested object
615
+		$class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db);
616
+		if ($this->_cache_on && $cache) {
617
+			// save it for later... kinda like gum  { : $
618
+			$this->_set_cached_class($class_obj, $class_name, $addon, $from_db);
619
+		}
620
+		$this->_cache_on = true;
621
+		return $class_obj;
622
+	}
623
+
624
+
625
+
626
+	/**
627
+	 * instantiates, caches, and injects dependencies for classes
628
+	 *
629
+	 * @param array       $file_paths   an array of paths to folders to look in
630
+	 * @param string      $class_prefix EE  or EEM or... ???
631
+	 * @param bool|string $class_name   $class name
632
+	 * @param string      $type         file type - core? class? helper? model?
633
+	 * @param mixed       $arguments    an argument or array of arguments to pass to the class upon instantiation
634
+	 * @param bool        $from_db      some classes are instantiated from the db
635
+	 *                                  and thus call a different method to instantiate
636
+	 * @param bool        $cache        whether to cache the instantiated object for reuse
637
+	 * @param bool        $load_only    if true, will only load the file, but will NOT instantiate an object
638
+	 * @return null|object|bool         null = failure to load or instantiate class object.
639
+	 *                                  object = class loaded and instantiated successfully.
640
+	 *                                  bool = fail or success when $load_only is true
641
+	 */
642
+	protected function _load(
643
+		$file_paths = array(),
644
+		$class_prefix = 'EE_',
645
+		$class_name = false,
646
+		$type = 'class',
647
+		$arguments = array(),
648
+		$from_db = false,
649
+		$cache = true,
650
+		$load_only = false
651
+	) {
652
+		// strip php file extension
653
+		$class_name = str_replace('.php', '', trim($class_name));
654
+		// does the class have a prefix ?
655
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
656
+			// make sure $class_prefix is uppercase
657
+			$class_prefix = strtoupper(trim($class_prefix));
658
+			// add class prefix ONCE!!!
659
+			$class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
660
+		}
661
+		$class_name = $this->_dependency_map->get_alias($class_name);
662
+		$class_exists = class_exists($class_name, false);
663
+		// if we're only loading the class and it already exists, then let's just return true immediately
664
+		if ($load_only && $class_exists) {
665
+			return true;
666
+		}
667
+		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
668
+		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
669
+		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
670
+		if ($this->_cache_on && $cache && ! $load_only) {
671
+			// return object if it's already cached
672
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
673
+			if ($cached_class !== null) {
674
+				return $cached_class;
675
+			}
676
+		}
677
+		// if the class doesn't already exist.. then we need to try and find the file and load it
678
+		if ( ! $class_exists) {
679
+			// get full path to file
680
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
681
+			// load the file
682
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
683
+			// if loading failed, or we are only loading a file but NOT instantiating an object
684
+			if ( ! $loaded || $load_only) {
685
+				// return boolean if only loading, or null if an object was expected
686
+				return $load_only ? $loaded : null;
687
+			}
688
+		}
689
+		// instantiate the requested object
690
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
691
+		if ($this->_cache_on && $cache) {
692
+			// save it for later... kinda like gum  { : $
693
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
694
+		}
695
+		$this->_cache_on = true;
696
+		return $class_obj;
697
+	}
698
+
699
+
700
+
701
+	/**
702
+	 * _get_cached_class
703
+	 * attempts to find a cached version of the requested class
704
+	 * by looking in the following places:
705
+	 *        $this->{$class_abbreviation}            ie:    $this->CART
706
+	 *        $this->{$class_name}                        ie:    $this->Some_Class
707
+	 *        $this->LIB->{$class_name}                ie:    $this->LIB->Some_Class
708
+	 *        $this->addon->{$class_name}    ie:    $this->addon->Some_Addon_Class
709
+	 *
710
+	 * @access protected
711
+	 * @param string $class_name
712
+	 * @param string $class_prefix
713
+	 * @return mixed
714
+	 */
715
+	protected function _get_cached_class($class_name, $class_prefix = '')
716
+	{
717
+		if (isset($this->_class_abbreviations[$class_name])) {
718
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
719
+		} else {
720
+			// have to specify something, but not anything that will conflict
721
+			$class_abbreviation = 'FANCY_BATMAN_PANTS';
722
+		}
723
+		// check if class has already been loaded, and return it if it has been
724
+		if (isset($this->{$class_abbreviation}) && ! is_null($this->{$class_abbreviation})) {
725
+			return $this->{$class_abbreviation};
726
+		} else if (isset ($this->{$class_name})) {
727
+			return $this->{$class_name};
728
+		} else if (isset ($this->LIB->{$class_name})) {
729
+			return $this->LIB->{$class_name};
730
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name})) {
731
+			return $this->addons->{$class_name};
732
+		}
733
+		return null;
734
+	}
735
+
736
+
737
+
738
+	/**
739
+	 * _resolve_path
740
+	 * attempts to find a full valid filepath for the requested class.
741
+	 * loops thru each of the base paths in the $file_paths array and appends : "{classname} . {file type} . php"
742
+	 * then returns that path if the target file has been found and is readable
743
+	 *
744
+	 * @access protected
745
+	 * @param string $class_name
746
+	 * @param string $type
747
+	 * @param array  $file_paths
748
+	 * @return string | bool
749
+	 */
750
+	protected function _resolve_path($class_name, $type = '', $file_paths = array())
751
+	{
752
+		// make sure $file_paths is an array
753
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
754
+		// cycle thru paths
755
+		foreach ($file_paths as $key => $file_path) {
756
+			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
757
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
758
+			// prep file type
759
+			$type = ! empty($type) ? trim($type, '.') . '.' : '';
760
+			// build full file path
761
+			$file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
762
+			//does the file exist and can be read ?
763
+			if (is_readable($file_paths[$key])) {
764
+				return $file_paths[$key];
765
+			}
766
+		}
767
+		return false;
768
+	}
769
+
770
+
771
+
772
+	/**
773
+	 * _require_file
774
+	 * basically just performs a require_once()
775
+	 * but with some error handling
776
+	 *
777
+	 * @access protected
778
+	 * @param  string $path
779
+	 * @param  string $class_name
780
+	 * @param  string $type
781
+	 * @param  array  $file_paths
782
+	 * @return boolean
783
+	 * @throws \EE_Error
784
+	 */
785
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array())
786
+	{
787
+		$this->resolve_legacy_class_parent($class_name);
788
+		// don't give up! you gotta...
789
+		try {
790
+			//does the file exist and can it be read ?
791
+			if ( ! $path) {
792
+				// so sorry, can't find the file
793
+				throw new EE_Error (
794
+					sprintf(
795
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
796
+						trim($type, '.'),
797
+						$class_name,
798
+						'<br />' . implode(',<br />', $file_paths)
799
+					)
800
+				);
801
+			}
802
+			// get the file
803
+			require_once($path);
804
+			// if the class isn't already declared somewhere
805
+			if (class_exists($class_name, false) === false) {
806
+				// so sorry, not a class
807
+				throw new EE_Error(
808
+					sprintf(
809
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
810
+						$type,
811
+						$path,
812
+						$class_name
813
+					)
814
+				);
815
+			}
816
+		} catch (EE_Error $e) {
817
+			$e->get_error();
818
+			return false;
819
+		}
820
+		return true;
821
+	}
822
+
823
+
824
+
825
+	/**
826
+	 * Some of our legacy classes that extended a parent class would simply use a require() statement
827
+	 * before their class declaration in order to ensure that the parent class was loaded.
828
+	 * This is not ideal, but it's nearly impossible to determine the parent class of a non-namespaced class,
829
+	 * without triggering a fatal error because the parent class has yet to be loaded and therefore doesn't exist.
830
+	 *
831
+	 * @param string $class_name
832
+	 */
833
+	protected function resolve_legacy_class_parent($class_name = '')
834
+	{
835
+		try {
836
+			$legacy_parent_class_map = array(
837
+				'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php'
838
+			);
839
+			if(isset($legacy_parent_class_map[$class_name])) {
840
+				require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[$class_name];
841
+			}
842
+		} catch (Exception $exception) {
843
+		}
844
+	}
845
+
846
+
847
+
848
+	/**
849
+	 * _create_object
850
+	 * Attempts to instantiate the requested class via any of the
851
+	 * commonly used instantiation methods employed throughout EE.
852
+	 * The priority for instantiation is as follows:
853
+	 *        - abstract classes or any class flagged as "load only" (no instantiation occurs)
854
+	 *        - model objects via their 'new_instance_from_db' method
855
+	 *        - model objects via their 'new_instance' method
856
+	 *        - "singleton" classes" via their 'instance' method
857
+	 *    - standard instantiable classes via their __constructor
858
+	 * Prior to instantiation, if the classname exists in the dependency_map,
859
+	 * then the constructor for the requested class will be examined to determine
860
+	 * if any dependencies exist, and if they can be injected.
861
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
862
+	 *
863
+	 * @access protected
864
+	 * @param string $class_name
865
+	 * @param array  $arguments
866
+	 * @param string $type
867
+	 * @param bool   $from_db
868
+	 * @return null | object
869
+	 * @throws \EE_Error
870
+	 */
871
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false)
872
+	{
873
+		$class_obj = null;
874
+		$instantiation_mode = '0) none';
875
+		// don't give up! you gotta...
876
+		try {
877
+			// create reflection
878
+			$reflector = $this->get_ReflectionClass($class_name);
879
+			// make sure arguments are an array
880
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
881
+			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
882
+			// else wrap it in an additional array so that it doesn't get split into multiple parameters
883
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
884
+				? $arguments
885
+				: array($arguments);
886
+			// attempt to inject dependencies ?
887
+			if ($this->_dependency_map->has($class_name)) {
888
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
889
+			}
890
+			// instantiate the class if possible
891
+			if ($reflector->isAbstract()) {
892
+				// nothing to instantiate, loading file was enough
893
+				// does not throw an exception so $instantiation_mode is unused
894
+				// $instantiation_mode = "1) no constructor abstract class";
895
+				$class_obj = true;
896
+			} else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) {
897
+				// no constructor = static methods only... nothing to instantiate, loading file was enough
898
+				$instantiation_mode = "2) no constructor but instantiable";
899
+				$class_obj = $reflector->newInstance();
900
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
901
+				$instantiation_mode = "3) new_instance_from_db()";
902
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
903
+			} else if (method_exists($class_name, 'new_instance')) {
904
+				$instantiation_mode = "4) new_instance()";
905
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
906
+			} else if (method_exists($class_name, 'instance')) {
907
+				$instantiation_mode = "5) instance()";
908
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
909
+			} else if ($reflector->isInstantiable()) {
910
+				$instantiation_mode = "6) constructor";
911
+				$class_obj = $reflector->newInstanceArgs($arguments);
912
+			} else {
913
+				// heh ? something's not right !
914
+				throw new EE_Error(
915
+					sprintf(
916
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
917
+						$type,
918
+						$class_name
919
+					)
920
+				);
921
+			}
922
+		} catch (Exception $e) {
923
+			if ( ! $e instanceof EE_Error) {
924
+				$e = new EE_Error(
925
+					sprintf(
926
+						__('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'),
927
+						$class_name,
928
+						'<br />',
929
+						$e->getMessage(),
930
+						$instantiation_mode
931
+					)
932
+				);
933
+			}
934
+			$e->get_error();
935
+		}
936
+		return $class_obj;
937
+	}
938
+
939
+
940
+
941
+	/**
942
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
943
+	 * @param array $array
944
+	 * @return bool
945
+	 */
946
+	protected function _array_is_numerically_and_sequentially_indexed(array $array)
947
+	{
948
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
949
+	}
950
+
951
+
952
+
953
+	/**
954
+	 * getReflectionClass
955
+	 * checks if a ReflectionClass object has already been generated for a class
956
+	 * and returns that instead of creating a new one
957
+	 *
958
+	 * @access public
959
+	 * @param string $class_name
960
+	 * @return ReflectionClass
961
+	 */
962
+	public function get_ReflectionClass($class_name)
963
+	{
964
+		if (
965
+			! isset($this->_reflectors[$class_name])
966
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
967
+		) {
968
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
969
+		}
970
+		return $this->_reflectors[$class_name];
971
+	}
972
+
973
+
974
+
975
+	/**
976
+	 * _resolve_dependencies
977
+	 * examines the constructor for the requested class to determine
978
+	 * if any dependencies exist, and if they can be injected.
979
+	 * If so, then those classes will be added to the array of arguments passed to the constructor
980
+	 * PLZ NOTE: this is achieved by type hinting the constructor params
981
+	 * For example:
982
+	 *        if attempting to load a class "Foo" with the following constructor:
983
+	 *        __construct( Bar $bar_class, Fighter $grohl_class )
984
+	 *        then $bar_class and $grohl_class will be added to the $arguments array,
985
+	 *        but only IF they are NOT already present in the incoming arguments array,
986
+	 *        and the correct classes can be loaded
987
+	 *
988
+	 * @access protected
989
+	 * @param ReflectionClass $reflector
990
+	 * @param string          $class_name
991
+	 * @param array           $arguments
992
+	 * @return array
993
+	 * @throws \ReflectionException
994
+	 */
995
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array())
996
+	{
997
+		// let's examine the constructor
998
+		$constructor = $reflector->getConstructor();
999
+		// whu? huh? nothing?
1000
+		if ( ! $constructor) {
1001
+			return $arguments;
1002
+		}
1003
+		// get constructor parameters
1004
+		$params = $constructor->getParameters();
1005
+		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
1006
+		$argument_keys = array_keys($arguments);
1007
+		// now loop thru all of the constructors expected parameters
1008
+		foreach ($params as $index => $param) {
1009
+			// is this a dependency for a specific class ?
1010
+			$param_class = $param->getClass() ? $param->getClass()->name : null;
1011
+			if (
1012
+				// param is not even a class
1013
+				empty($param_class)
1014
+				// and something already exists in the incoming arguments for this param
1015
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1016
+			) {
1017
+				// so let's skip this argument and move on to the next
1018
+				continue;
1019
+			} else if (
1020
+				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
1021
+				! empty($param_class)
1022
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
1023
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
1024
+			) {
1025
+				// skip this argument and move on to the next
1026
+				continue;
1027
+			} else if (
1028
+				// parameter is type hinted as a class, and should be injected
1029
+				! empty($param_class)
1030
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
1031
+			) {
1032
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
1033
+			} else {
1034
+				try {
1035
+					$arguments[$index] = $param->getDefaultValue();
1036
+				} catch (ReflectionException $e) {
1037
+					throw new ReflectionException(
1038
+						sprintf(
1039
+							__('%1$s for parameter "$%2$s"', 'event_espresso'),
1040
+							$e->getMessage(),
1041
+							$param->getName()
1042
+						)
1043
+					);
1044
+				}
1045
+			}
1046
+		}
1047
+		return $arguments;
1048
+	}
1049
+
1050
+
1051
+
1052
+	/**
1053
+	 * @access protected
1054
+	 * @param string $class_name
1055
+	 * @param string $param_class
1056
+	 * @param array  $arguments
1057
+	 * @param mixed  $index
1058
+	 * @return array
1059
+	 */
1060
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index)
1061
+	{
1062
+		$dependency = null;
1063
+		// should dependency be loaded from cache ?
1064
+		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class)
1065
+					!== EE_Dependency_Map::load_new_object
1066
+			? true
1067
+			: false;
1068
+		// we might have a dependency...
1069
+		// let's MAYBE try and find it in our cache if that's what's been requested
1070
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
1071
+		// and grab it if it exists
1072
+		if ($cached_class instanceof $param_class) {
1073
+			$dependency = $cached_class;
1074
+		} else if ($param_class != $class_name) {
1075
+			// obtain the loader method from the dependency map
1076
+			$loader = $this->_dependency_map->class_loader($param_class);
1077
+			// is loader a custom closure ?
1078
+			if ($loader instanceof Closure) {
1079
+				$dependency = $loader();
1080
+			} else {
1081
+				// set the cache on property for the recursive loading call
1082
+				$this->_cache_on = $cache_on;
1083
+				// if not, then let's try and load it via the registry
1084
+				if (method_exists($this, $loader)) {
1085
+					$dependency = $this->{$loader}($param_class);
1086
+				} else {
1087
+					$dependency = $this->create($param_class, array(), $cache_on);
1088
+				}
1089
+			}
1090
+		}
1091
+		// did we successfully find the correct dependency ?
1092
+		if ($dependency instanceof $param_class) {
1093
+			// then let's inject it into the incoming array of arguments at the correct location
1094
+			if (isset($argument_keys[$index])) {
1095
+				$arguments[$argument_keys[$index]] = $dependency;
1096
+			} else {
1097
+				$arguments[$index] = $dependency;
1098
+			}
1099
+		}
1100
+		return $arguments;
1101
+	}
1102
+
1103
+
1104
+
1105
+	/**
1106
+	 * _set_cached_class
1107
+	 * attempts to cache the instantiated class locally
1108
+	 * in one of the following places, in the following order:
1109
+	 *        $this->{class_abbreviation}   ie:    $this->CART
1110
+	 *        $this->{$class_name}          ie:    $this->Some_Class
1111
+	 *        $this->addon->{$$class_name}    ie:    $this->addon->Some_Addon_Class
1112
+	 *        $this->LIB->{$class_name}     ie:    $this->LIB->Some_Class
1113
+	 *
1114
+	 * @access protected
1115
+	 * @param object $class_obj
1116
+	 * @param string $class_name
1117
+	 * @param string $class_prefix
1118
+	 * @param bool   $from_db
1119
+	 * @return void
1120
+	 */
1121
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false)
1122
+	{
1123
+		if (empty($class_obj)) {
1124
+			return;
1125
+		}
1126
+		// return newly instantiated class
1127
+		if (isset($this->_class_abbreviations[$class_name])) {
1128
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
1129
+			$this->{$class_abbreviation} = $class_obj;
1130
+		} else if (property_exists($this, $class_name)) {
1131
+			$this->{$class_name} = $class_obj;
1132
+		} else if ($class_prefix == 'addon') {
1133
+			$this->addons->{$class_name} = $class_obj;
1134
+		} else if ( ! $from_db) {
1135
+			$this->LIB->{$class_name} = $class_obj;
1136
+		}
1137
+	}
1138
+
1139
+
1140
+
1141
+	/**
1142
+	 * call any loader that's been registered in the EE_Dependency_Map::$_class_loaders array
1143
+	 *
1144
+	 * @param string $classname PLEASE NOTE: the class name needs to match what's registered
1145
+	 *                          in the EE_Dependency_Map::$_class_loaders array,
1146
+	 *                          including the class prefix, ie: "EE_", "EEM_", "EEH_", etc
1147
+	 * @param array  $arguments
1148
+	 * @return object
1149
+	 */
1150
+	public static function factory($classname, $arguments = array())
1151
+	{
1152
+		$loader = self::instance()->_dependency_map->class_loader($classname);
1153
+		if ($loader instanceof Closure) {
1154
+			return $loader($arguments);
1155
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
1156
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
1157
+		}
1158
+		return null;
1159
+	}
1160
+
1161
+
1162
+
1163
+	/**
1164
+	 * Gets the addon by its name/slug (not classname. For that, just
1165
+	 * use the classname as the property name on EE_Config::instance()->addons)
1166
+	 *
1167
+	 * @param string $name
1168
+	 * @return EE_Addon
1169
+	 */
1170
+	public function get_addon_by_name($name)
1171
+	{
1172
+		foreach ($this->addons as $addon) {
1173
+			if ($addon->name() == $name) {
1174
+				return $addon;
1175
+			}
1176
+		}
1177
+		return null;
1178
+	}
1179
+
1180
+
1181
+
1182
+	/**
1183
+	 * Gets an array of all the registered addons, where the keys are their names. (ie, what each returns for their name() function) They're already available on EE_Config::instance()->addons as properties, where each property's name is
1184
+	 * the addon's classname. So if you just want to get the addon by classname, use EE_Config::instance()->addons->{classname}
1185
+	 *
1186
+	 * @return EE_Addon[] where the KEYS are the addon's name()
1187
+	 */
1188
+	public function get_addons_by_name()
1189
+	{
1190
+		$addons = array();
1191
+		foreach ($this->addons as $addon) {
1192
+			$addons[$addon->name()] = $addon;
1193
+		}
1194
+		return $addons;
1195
+	}
1196
+
1197
+
1198
+
1199
+	/**
1200
+	 * Resets the specified model's instance AND makes sure EE_Registry doesn't keep
1201
+	 * a stale copy of it around
1202
+	 *
1203
+	 * @param string $model_name
1204
+	 * @return \EEM_Base
1205
+	 * @throws \EE_Error
1206
+	 */
1207
+	public function reset_model($model_name)
1208
+	{
1209
+		$model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name;
1210
+		if ( ! isset($this->LIB->{$model_class_name}) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) {
1211
+			return null;
1212
+		}
1213
+		//get that model reset it and make sure we nuke the old reference to it
1214
+		if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1215
+			$this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset();
1216
+		} else {
1217
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1218
+		}
1219
+		return $this->LIB->{$model_class_name};
1220
+	}
1221
+
1222
+
1223
+
1224
+	/**
1225
+	 * Resets the registry.
1226
+	 * The criteria for what gets reset is based on what can be shared between sites on the same request when switch_to_blog
1227
+	 * is used in a multisite install.  Here is a list of things that are NOT reset.
1228
+	 * - $_dependency_map
1229
+	 * - $_class_abbreviations
1230
+	 * - $NET_CFG (EE_Network_Config): The config is shared network wide so no need to reset.
1231
+	 * - $REQ:  Still on the same request so no need to change.
1232
+	 * - $CAP: There is no site specific state in the EE_Capability class.
1233
+	 * - $SSN: Although ideally, the session should not be shared between site switches, we can't reset it because only one Session
1234
+	 *         can be active in a single request.  Resetting could resolve in "headers already sent" errors.
1235
+	 * - $addons:  In multisite, the state of the addons is something controlled via hooks etc in a normal request.  So
1236
+	 *             for now, we won't reset the addons because it could break calls to an add-ons class/methods in the
1237
+	 *             switch or on the restore.
1238
+	 * - $modules
1239
+	 * - $shortcodes
1240
+	 * - $widgets
1241
+	 *
1242
+	 * @param boolean $hard             whether to reset data in the database too, or just refresh
1243
+	 *                                  the Registry to its state at the beginning of the request
1244
+	 * @param boolean $reinstantiate    whether to create new instances of EE_Registry's singletons too,
1245
+	 *                                  or just reset without re-instantiating (handy to set to FALSE if you're not sure if you CAN
1246
+	 *                                  currently reinstantiate the singletons at the moment)
1247
+	 * @param   bool  $reset_models     Defaults to true.  When false, then the models are not reset.  This is so client
1248
+	 *                                  code instead can just change the model context to a different blog id if necessary
1249
+	 * @return EE_Registry
1250
+	 */
1251
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true)
1252
+	{
1253
+		$instance = self::instance();
1254
+		EEH_Activation::reset();
1255
+		//properties that get reset
1256
+		$instance->_cache_on = true;
1257
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1258
+		$instance->CART = null;
1259
+		$instance->MRM = null;
1260
+		$instance->AssetsRegistry = new Registry();
1261
+		//messages reset
1262
+		EED_Messages::reset();
1263
+		if ($reset_models) {
1264
+			foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1265
+				$instance->reset_model($model_name);
1266
+			}
1267
+		}
1268
+		$instance->LIB = new stdClass();
1269
+		return $instance;
1270
+	}
1271
+
1272
+
1273
+
1274
+	/**
1275
+	 * @override magic methods
1276
+	 * @return void
1277
+	 */
1278
+	final function __destruct()
1279
+	{
1280
+	}
1281
+
1282
+
1283
+
1284
+	/**
1285
+	 * @param $a
1286
+	 * @param $b
1287
+	 */
1288
+	final function __call($a, $b)
1289
+	{
1290
+	}
1291
+
1292
+
1293
+
1294
+	/**
1295
+	 * @param $a
1296
+	 */
1297
+	final function __get($a)
1298
+	{
1299
+	}
1300
+
1301
+
1302
+
1303
+	/**
1304
+	 * @param $a
1305
+	 * @param $b
1306
+	 */
1307
+	final function __set($a, $b)
1308
+	{
1309
+	}
1310
+
1311
+
1312
+
1313
+	/**
1314
+	 * @param $a
1315
+	 */
1316
+	final function __isset($a)
1317
+	{
1318
+	}
1319 1319
 
1320 1320
 
1321 1321
 
1322
-    /**
1323
-     * @param $a
1324
-     */
1325
-    final function __unset($a)
1326
-    {
1327
-    }
1322
+	/**
1323
+	 * @param $a
1324
+	 */
1325
+	final function __unset($a)
1326
+	{
1327
+	}
1328 1328
 
1329 1329
 
1330 1330
 
1331
-    /**
1332
-     * @return array
1333
-     */
1334
-    final function __sleep()
1335
-    {
1336
-        return array();
1337
-    }
1331
+	/**
1332
+	 * @return array
1333
+	 */
1334
+	final function __sleep()
1335
+	{
1336
+		return array();
1337
+	}
1338 1338
 
1339 1339
 
1340 1340
 
1341
-    final function __wakeup()
1342
-    {
1343
-    }
1341
+	final function __wakeup()
1342
+	{
1343
+	}
1344 1344
 
1345 1345
 
1346 1346
 
1347
-    /**
1348
-     * @return string
1349
-     */
1350
-    final function __toString()
1351
-    {
1352
-        return '';
1353
-    }
1347
+	/**
1348
+	 * @return string
1349
+	 */
1350
+	final function __toString()
1351
+	{
1352
+		return '';
1353
+	}
1354 1354
 
1355 1355
 
1356 1356
 
1357
-    final function __invoke()
1358
-    {
1359
-    }
1357
+	final function __invoke()
1358
+	{
1359
+	}
1360 1360
 
1361 1361
 
1362 1362
 
1363
-    final static function __set_state()
1364
-    {
1365
-    }
1363
+	final static function __set_state()
1364
+	{
1365
+	}
1366 1366
 
1367 1367
 
1368 1368
 
1369
-    final function __clone()
1370
-    {
1371
-    }
1369
+	final function __clone()
1370
+	{
1371
+	}
1372 1372
 
1373 1373
 
1374 1374
 
1375
-    /**
1376
-     * @param $a
1377
-     * @param $b
1378
-     */
1379
-    final static function __callStatic($a, $b)
1380
-    {
1381
-    }
1375
+	/**
1376
+	 * @param $a
1377
+	 * @param $b
1378
+	 */
1379
+	final static function __callStatic($a, $b)
1380
+	{
1381
+	}
1382 1382
 
1383 1383
 
1384 1384
 
1385
-    /**
1386
-     * Gets all the custom post type models defined
1387
-     *
1388
-     * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1389
-     */
1390
-    public function cpt_models()
1391
-    {
1392
-        $cpt_models = array();
1393
-        foreach ($this->non_abstract_db_models as $short_name => $classname) {
1394
-            if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1395
-                $cpt_models[$short_name] = $classname;
1396
-            }
1397
-        }
1398
-        return $cpt_models;
1399
-    }
1385
+	/**
1386
+	 * Gets all the custom post type models defined
1387
+	 *
1388
+	 * @return array keys are model "short names" (Eg "Event") and keys are classnames (eg "EEM_Event")
1389
+	 */
1390
+	public function cpt_models()
1391
+	{
1392
+		$cpt_models = array();
1393
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1394
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1395
+				$cpt_models[$short_name] = $classname;
1396
+			}
1397
+		}
1398
+		return $cpt_models;
1399
+	}
1400 1400
 
1401 1401
 
1402 1402
 
1403
-    /**
1404
-     * @return \EE_Config
1405
-     */
1406
-    public static function CFG()
1407
-    {
1408
-        return self::instance()->CFG;
1409
-    }
1403
+	/**
1404
+	 * @return \EE_Config
1405
+	 */
1406
+	public static function CFG()
1407
+	{
1408
+		return self::instance()->CFG;
1409
+	}
1410 1410
 
1411 1411
 
1412 1412
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
      */
297 297
     public static function localize_i18n_js_strings()
298 298
     {
299
-        $i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
299
+        $i18n_js_strings = (array) EE_Registry::$i18n_js_strings;
300 300
         foreach ($i18n_js_strings as $key => $value) {
301 301
             if (is_scalar($value)) {
302
-                $i18n_js_strings[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8');
302
+                $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
303 303
             }
304 304
         }
305
-        return "/* <![CDATA[ */ var eei18n = " . wp_json_encode($i18n_js_strings) . '; /* ]]> */';
305
+        return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */';
306 306
     }
307 307
 
308 308
 
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
                 EE_CORE,
354 354
                 EE_ADMIN,
355 355
                 EE_CPTS,
356
-                EE_CORE . 'data_migration_scripts' . DS,
357
-                EE_CORE . 'request_stack' . DS,
358
-                EE_CORE . 'middleware' . DS,
356
+                EE_CORE.'data_migration_scripts'.DS,
357
+                EE_CORE.'request_stack'.DS,
358
+                EE_CORE.'middleware'.DS,
359 359
             )
360 360
         );
361 361
         // retrieve instantiated class
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
         $service_paths = apply_filters(
379 379
             'FHEE__EE_Registry__load_service__service_paths',
380 380
             array(
381
-                EE_CORE . 'services' . DS,
381
+                EE_CORE.'services'.DS,
382 382
             )
383 383
         );
384 384
         // retrieve instantiated class
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
     {
459 459
         $paths = array(
460 460
             EE_LIBRARIES,
461
-            EE_LIBRARIES . 'messages' . DS,
462
-            EE_LIBRARIES . 'shortcodes' . DS,
463
-            EE_LIBRARIES . 'qtips' . DS,
464
-            EE_LIBRARIES . 'payment_methods' . DS,
465
-            EE_LIBRARIES . 'messages' . DS . 'defaults' . DS,
461
+            EE_LIBRARIES.'messages'.DS,
462
+            EE_LIBRARIES.'shortcodes'.DS,
463
+            EE_LIBRARIES.'qtips'.DS,
464
+            EE_LIBRARIES.'payment_methods'.DS,
465
+            EE_LIBRARIES.'messages'.DS.'defaults'.DS,
466 466
         );
467 467
         // retrieve instantiated class
468 468
         return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
     public function load_model_class($class_name, $arguments = array(), $load_only = true)
502 502
     {
503 503
         $paths = array(
504
-            EE_MODELS . 'fields' . DS,
505
-            EE_MODELS . 'helpers' . DS,
506
-            EE_MODELS . 'relations' . DS,
507
-            EE_MODELS . 'strategies' . DS,
504
+            EE_MODELS.'fields'.DS,
505
+            EE_MODELS.'helpers'.DS,
506
+            EE_MODELS.'relations'.DS,
507
+            EE_MODELS.'strategies'.DS,
508 508
         );
509 509
         // retrieve instantiated class
510 510
         return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
         $class_name = $this->_dependency_map->get_alias($class_name);
591 591
         if ( ! class_exists($class_name)) {
592 592
             // maybe the class is registered with a preceding \
593
-            $class_name = strpos($class_name, '\\') !== 0 ? '\\' . $class_name : $class_name;
593
+            $class_name = strpos($class_name, '\\') !== 0 ? '\\'.$class_name : $class_name;
594 594
             // still doesn't exist ?
595 595
             if ( ! class_exists($class_name)) {
596 596
                 return null;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
             // make sure $class_prefix is uppercase
657 657
             $class_prefix = strtoupper(trim($class_prefix));
658 658
             // add class prefix ONCE!!!
659
-            $class_name = $class_prefix . str_replace($class_prefix, '', $class_name);
659
+            $class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
660 660
         }
661 661
         $class_name = $this->_dependency_map->get_alias($class_name);
662 662
         $class_exists = class_exists($class_name, false);
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
             // convert all separators to proper DS, if no filepath, then use EE_CLASSES
757 757
             $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
758 758
             // prep file type
759
-            $type = ! empty($type) ? trim($type, '.') . '.' : '';
759
+            $type = ! empty($type) ? trim($type, '.').'.' : '';
760 760
             // build full file path
761
-            $file_paths[$key] = rtrim($file_path, DS) . DS . $class_name . '.' . $type . 'php';
761
+            $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
762 762
             //does the file exist and can be read ?
763 763
             if (is_readable($file_paths[$key])) {
764 764
                 return $file_paths[$key];
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
             //does the file exist and can it be read ?
791 791
             if ( ! $path) {
792 792
                 // so sorry, can't find the file
793
-                throw new EE_Error (
793
+                throw new EE_Error(
794 794
                     sprintf(
795 795
                         __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
796 796
                         trim($type, '.'),
797 797
                         $class_name,
798
-                        '<br />' . implode(',<br />', $file_paths)
798
+                        '<br />'.implode(',<br />', $file_paths)
799 799
                     )
800 800
                 );
801 801
             }
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
             $legacy_parent_class_map = array(
837 837
                 'EE_Payment_Processor' => 'core/business/EE_Processor_Base.class.php'
838 838
             );
839
-            if(isset($legacy_parent_class_map[$class_name])) {
840
-                require_once EE_PLUGIN_DIR_PATH . $legacy_parent_class_map[$class_name];
839
+            if (isset($legacy_parent_class_map[$class_name])) {
840
+                require_once EE_PLUGIN_DIR_PATH.$legacy_parent_class_map[$class_name];
841 841
             }
842 842
         } catch (Exception $exception) {
843 843
         }
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Registration.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @since                 $VID:$
14 14
  */
15 15
 if (! defined('EVENT_ESPRESSO_VERSION')) {
16
-    exit('No direct script access allowed');
16
+	exit('No direct script access allowed');
17 17
 }
18 18
 
19 19
 
@@ -21,58 +21,58 @@  discard block
 block discarded – undo
21 21
 class Registration extends Calculations_Base
22 22
 {
23 23
 
24
-    /**
25
-     * Calculates the checkin status for each datetime this registration has access to
26
-     *
27
-     * @param array            $wpdb_row
28
-     * @param \WP_REST_Request $request
29
-     * @param Base             $controller
30
-     * @return int
31
-     * @throws \EE_Error
32
-     */
33
-    public static function datetime_checkin_stati($wpdb_row, $request, $controller)
34
-    {
35
-        if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) {
36
-            $reg = \EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']);
37
-        } else {
38
-            $reg = null;
39
-        }
40
-        if (! $reg instanceof \EE_Registration
41
-        ) {
42
-            throw new \EE_Error(
43
-                sprintf(
44
-                    __('Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found',
45
-                        'event_espresso'),
46
-                    $wpdb_row['Registration.REG_ID'],
47
-                    print_r($wpdb_row, true)
48
-                )
49
-            );
50
-        }
51
-        $datetime_ids = \EEM_Datetime::instance()->get_col(
52
-            array(
53
-                array(
54
-                    'Ticket.TKT_ID' => $reg->ticket_ID(),
55
-                ),
56
-                'default_where_conditions' => \EEM_Base::default_where_conditions_minimum_all
57
-            )
58
-        );
59
-        $checkin_stati = array();
60
-        foreach ($datetime_ids as $datetime_id) {
61
-            $status = $reg->check_in_status_for_datetime($datetime_id);
62
-            switch ($status) {
63
-                case \EE_Registration::checkin_status_out:
64
-                    $status_pretty = 'OUT';
65
-                    break;
66
-                case \EE_Registration::checkin_status_in:
67
-                    $status_pretty = 'IN';
68
-                    break;
69
-                case \EE_Registration::checkin_status_never:
70
-                default:
71
-                    $status_pretty = 'NEVER';
72
-                    break;
73
-            }
74
-            $checkin_stati[$datetime_id] = $status_pretty;
75
-        }
76
-        return $checkin_stati;
77
-    }
24
+	/**
25
+	 * Calculates the checkin status for each datetime this registration has access to
26
+	 *
27
+	 * @param array            $wpdb_row
28
+	 * @param \WP_REST_Request $request
29
+	 * @param Base             $controller
30
+	 * @return int
31
+	 * @throws \EE_Error
32
+	 */
33
+	public static function datetime_checkin_stati($wpdb_row, $request, $controller)
34
+	{
35
+		if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) {
36
+			$reg = \EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']);
37
+		} else {
38
+			$reg = null;
39
+		}
40
+		if (! $reg instanceof \EE_Registration
41
+		) {
42
+			throw new \EE_Error(
43
+				sprintf(
44
+					__('Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found',
45
+						'event_espresso'),
46
+					$wpdb_row['Registration.REG_ID'],
47
+					print_r($wpdb_row, true)
48
+				)
49
+			);
50
+		}
51
+		$datetime_ids = \EEM_Datetime::instance()->get_col(
52
+			array(
53
+				array(
54
+					'Ticket.TKT_ID' => $reg->ticket_ID(),
55
+				),
56
+				'default_where_conditions' => \EEM_Base::default_where_conditions_minimum_all
57
+			)
58
+		);
59
+		$checkin_stati = array();
60
+		foreach ($datetime_ids as $datetime_id) {
61
+			$status = $reg->check_in_status_for_datetime($datetime_id);
62
+			switch ($status) {
63
+				case \EE_Registration::checkin_status_out:
64
+					$status_pretty = 'OUT';
65
+					break;
66
+				case \EE_Registration::checkin_status_in:
67
+					$status_pretty = 'IN';
68
+					break;
69
+				case \EE_Registration::checkin_status_never:
70
+				default:
71
+					$status_pretty = 'NEVER';
72
+					break;
73
+			}
74
+			$checkin_stati[$datetime_id] = $status_pretty;
75
+		}
76
+		return $checkin_stati;
77
+	}
78 78
 }
Please login to merge, or discard this patch.