Completed
Branch FET-9950-select2-event-datetim... (0d2c7a)
by
unknown
66:16 queued 48:38
created
core/libraries/rest_api/Model_Data_Translator.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
 	 *
102 102
 	 * @param \EE_Model_Field_Base $field_obj
103 103
 	 * @param mixed                $original_value
104
-	 * @param                      $requested_version
104
+	 * @param                      string $requested_version
105 105
 	 * @return mixed
106 106
 	 */
107 107
    public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) {
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@
 block discarded – undo
125 125
 			$original_value,
126 126
 			$requested_version
127 127
 		);
128
-    }
128
+	}
129 129
 
130 130
 
131 131
 
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
 	 * @param string  $requested_version
42 42
 	 * @return mixed
43 43
 	 */
44
-	public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) {
45
-		if( is_array( $original_value_maybe_array ) ) {
44
+	public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) {
45
+		if (is_array($original_value_maybe_array)) {
46 46
 			$new_value_maybe_array = array();
47
-			foreach( $original_value_maybe_array as $array_key => $array_item ) {
48
-				$new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $array_item, $requested_version );
47
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
48
+				$new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json($field_obj, $array_item, $requested_version);
49 49
 			}
50 50
 		} else {
51
-			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version );
51
+			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version);
52 52
 		}
53 53
 		return $new_value_maybe_array;
54 54
 	}
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 	 * @param string $request_version (eg 4.8.36)
62 62
 	 * @return array
63 63
 	 */
64
-	public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ){
65
-		if( is_array( $original_value_maybe_array ) ) {
64
+	public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) {
65
+		if (is_array($original_value_maybe_array)) {
66 66
 			$new_value_maybe_array = array();
67
-			foreach( $original_value_maybe_array as $array_key => $array_item ) {
68
-				$new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $array_item, $request_version );
67
+			foreach ($original_value_maybe_array as $array_key => $array_item) {
68
+				$new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json($field_obj, $array_item, $request_version);
69 69
 			}
70 70
 		} else {
71
-			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json( $field_obj, $original_value_maybe_array, $request_version );
71
+			$new_value_maybe_array = Model_Data_Translator::prepare_field_value_for_json($field_obj, $original_value_maybe_array, $request_version);
72 72
 		}
73 73
 		return $new_value_maybe_array;
74 74
 	}
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 * @param string $requested_version
82 82
 	 * @return mixed
83 83
 	 */
84
-	public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) {
84
+	public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) {
85 85
 		$new_value = null;
86
-		if( $field_obj instanceof \EE_Infinite_Integer_Field
87
-			&& in_array( $original_value, array( null, '' ), true ) ) {
86
+		if ($field_obj instanceof \EE_Infinite_Integer_Field
87
+			&& in_array($original_value, array(null, ''), true)) {
88 88
 			$new_value = EE_INF;
89
-		} elseif( $field_obj instanceof \EE_Datetime_Field ) {
90
-			$new_value = rest_parse_date( $original_value );
89
+		} elseif ($field_obj instanceof \EE_Datetime_Field) {
90
+			$new_value = rest_parse_date($original_value);
91 91
 		} else {
92 92
 			$new_value = $original_value;
93 93
 		}
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 	 * @param                      $requested_version
105 105
 	 * @return mixed
106 106
 	 */
107
-   public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) {
108
-		if( $original_value === EE_INF ) {
107
+   public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) {
108
+		if ($original_value === EE_INF) {
109 109
 			$new_value = Model_Data_Translator::ee_inf_in_rest;
110
-		} elseif( $field_obj instanceof \EE_Datetime_Field ) {
111
-			if( $original_value instanceof \DateTime ) {
112
-				$new_value = $original_value->format( 'Y-m-d H:i:s' );
113
-			} elseif( is_int( $original_value ) ) {
114
-				$new_value = date( 'Y-m-d H:i:s', $original_value );
110
+		} elseif ($field_obj instanceof \EE_Datetime_Field) {
111
+			if ($original_value instanceof \DateTime) {
112
+				$new_value = $original_value->format('Y-m-d H:i:s');
113
+			} elseif (is_int($original_value)) {
114
+				$new_value = date('Y-m-d H:i:s', $original_value);
115 115
 			} else {
116 116
 				$new_value = $original_value;
117 117
 			}
118
-			$new_value = mysql_to_rfc3339( $new_value );
118
+			$new_value = mysql_to_rfc3339($new_value);
119 119
 		} else {
120 120
 			$new_value = $original_value;
121 121
 		}
122
-		return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
122
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api',
123 123
 			$new_value,
124 124
 			$field_obj,
125 125
 			$original_value,
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 	 * @return array
140 140
 	 * @throws \EE_Error
141 141
 	 */
142
-	public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) {
142
+	public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) {
143 143
 		$query_param_for_models = array();
144
-		foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) {
144
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
145 145
 			$field = Model_Data_Translator::deduce_field_from_query_param(
146
-				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ),
146
+				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key),
147 147
 				$model
148 148
 			);
149
-			if( $field instanceof \EE_Model_Field_Base ) {
149
+			if ($field instanceof \EE_Model_Field_Base) {
150 150
 				//did they specify an operator?
151
-				if( is_array( $query_param_value ) ) {
152
-					$op = $query_param_value[ 0 ];
153
-					$translated_value = array( $op );
154
-					if( isset( $query_param_value[ 1 ] ) ) {
155
-						$value = $query_param_value[ 1 ];
156
-						$translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version );
151
+				if (is_array($query_param_value)) {
152
+					$op = $query_param_value[0];
153
+					$translated_value = array($op);
154
+					if (isset($query_param_value[1])) {
155
+						$value = $query_param_value[1];
156
+						$translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version);
157 157
 					}
158 158
 				} else {
159
-					$translated_value  = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version );
159
+					$translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version);
160 160
 				}
161
-				$query_param_for_models[ $query_param_key ] = $translated_value;
161
+				$query_param_for_models[$query_param_key] = $translated_value;
162 162
 			} else {
163 163
 				//so it's not for a field, assume it's a logic query param key
164
-				$query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version );
164
+				$query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version);
165 165
 			}
166 166
 		}
167 167
 		return $query_param_for_models;
@@ -176,27 +176,27 @@  discard block
 block discarded – undo
176 176
 	 * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API
177 177
 	 * @return array which can be passed into the EE4 REST API when querying a model resource
178 178
 	 */
179
-	public static function prepare_query_params_for_rest_api( array $model_query_params, \EEM_Base $model,  $requested_version = null ) {
180
-		if( $requested_version === null ) {
181
-			$requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ;
179
+	public static function prepare_query_params_for_rest_api(array $model_query_params, \EEM_Base $model, $requested_version = null) {
180
+		if ($requested_version === null) {
181
+			$requested_version = \EED_Core_Rest_Api::latest_rest_api_version();
182 182
 		}
183 183
 		$rest_query_params = $model_query_params;
184
-		if ( isset( $model_query_params[0] ) ) {
185
-			$rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
186
-				$model_query_params[ 0 ],
184
+		if (isset($model_query_params[0])) {
185
+			$rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
186
+				$model_query_params[0],
187 187
 				$model,
188 188
 				$requested_version
189 189
 			);
190
-			unset( $rest_query_params[0] );
190
+			unset($rest_query_params[0]);
191 191
 		}
192
-		if ( isset( $model_query_params[ 'having' ] ) ) {
193
-			$rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
194
-				$model_query_params[ 'having' ],
192
+		if (isset($model_query_params['having'])) {
193
+			$rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api(
194
+				$model_query_params['having'],
195 195
 				$model,
196 196
 				$requested_version
197 197
 			);
198 198
 		}
199
-		return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version );
199
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,29 +206,29 @@  discard block
 block discarded – undo
206 206
 	 * @param string $requested_version eg "4.8.36"
207 207
 	 * @return array ready for use in the rest api query params
208 208
 	 */
209
-	public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) {
209
+	public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) {
210 210
 		$query_param_for_models = array();
211
-		foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) {
211
+		foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) {
212 212
 			$field = Model_Data_Translator::deduce_field_from_query_param(
213
-				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ),
213
+				Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key),
214 214
 				$model
215 215
 			);
216
-			if( $field instanceof \EE_Model_Field_Base ) {
216
+			if ($field instanceof \EE_Model_Field_Base) {
217 217
 				//did they specify an operator?
218
-				if( is_array( $query_param_value ) ) {
219
-					$op = $query_param_value[ 0 ];
220
-					$translated_value = array( $op );
221
-					if( isset( $query_param_value[ 1 ] ) ) {
222
-						$value = $query_param_value[ 1 ];
223
-						$translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version );
218
+				if (is_array($query_param_value)) {
219
+					$op = $query_param_value[0];
220
+					$translated_value = array($op);
221
+					if (isset($query_param_value[1])) {
222
+						$value = $query_param_value[1];
223
+						$translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version);
224 224
 					}
225 225
 				} else {
226
-					$translated_value  = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version );
226
+					$translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version);
227 227
 				}
228
-				$query_param_for_models[ $query_param_key ] = $translated_value;
228
+				$query_param_for_models[$query_param_key] = $translated_value;
229 229
 			} else {
230 230
 				//so it's not for a field, assume it's a logic query param key
231
-				$query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version );
231
+				$query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version);
232 232
 			}
233 233
 		}
234 234
 		return $query_param_for_models;
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	 * @param $condition_query_param_key
241 241
 	 * @return string
242 242
 	 */
243
-	public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) {
243
+	public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
244 244
 		$pos_of_star = strpos($condition_query_param_key, '*');
245
-		if($pos_of_star === FALSE){
245
+		if ($pos_of_star === FALSE) {
246 246
 			return $condition_query_param_key;
247
-		}else{
247
+		} else {
248 248
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
249 249
 			return $condition_query_param_sans_star;
250 250
 		}
@@ -260,26 +260,26 @@  discard block
 block discarded – undo
260 260
 	 * @return \EE_Model_Field_Base
261 261
 	 * @throws \EE_Error
262 262
 	 */
263
-	public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){
263
+	public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) {
264 264
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
265 265
 		//which will help us find the database table and column
266 266
 
267
-		$query_param_parts = explode(".",$query_param_name);
268
-		if(empty($query_param_parts)){
269
-			throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
267
+		$query_param_parts = explode(".", $query_param_name);
268
+		if (empty($query_param_parts)) {
269
+			throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
270 270
 		}
271 271
 		$number_of_parts = count($query_param_parts);
272
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
273
-		if($number_of_parts == 1){
272
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
273
+		if ($number_of_parts == 1) {
274 274
 			$field_name = $last_query_param_part;
275
-		}else{// $number_of_parts >= 2
275
+		} else {// $number_of_parts >= 2
276 276
 			//the last part is the column name, and there are only 2parts. therefore...
277 277
 			$field_name = $last_query_param_part;
278
-			$model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]);
278
+			$model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]);
279 279
 		}
280
-		try{
280
+		try {
281 281
 			return $model->field_settings_for($field_name);
282
-		}catch(\EE_Error $e){
282
+		} catch (\EE_Error $e) {
283 283
 			return null;
284 284
 		}
285 285
 	}
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/SequentialStepFormManager.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 use Exception;
17 17
 use InvalidArgumentException;
18 18
 
19
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
20
-	exit( 'No direct script access allowed' );
19
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
20
+	exit('No direct script access allowed');
21 21
 }
22 22
 
23 23
 
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 		$progress_step_style = 'number_bubbles',
116 116
 		EE_Request $request
117 117
 	) {
118
-		$this->setBaseUrl( $base_url );
119
-		$this->setDefaultFormStep( $default_form_step );
120
-		$this->setFormAction( $form_action );
121
-		$this->setFormConfig( $form_config );
122
-		$this->setProgressStepStyle( $progress_step_style );
118
+		$this->setBaseUrl($base_url);
119
+		$this->setDefaultFormStep($default_form_step);
120
+		$this->setFormAction($form_action);
121
+		$this->setFormConfig($form_config);
122
+		$this->setProgressStepStyle($progress_step_style);
123 123
 		$this->request = $request;
124 124
 	}
125 125
 
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
131 131
 	 */
132 132
 	public function baseUrl() {
133
-		if ( strpos( $this->base_url, $this->getCurrentStep()->slug() ) === false ) {
133
+		if (strpos($this->base_url, $this->getCurrentStep()->slug()) === false) {
134 134
 			add_query_arg(
135
-				array( $this->form_step_url_key => $this->getCurrentStep()->slug() ),
135
+				array($this->form_step_url_key => $this->getCurrentStep()->slug()),
136 136
 				$this->base_url
137 137
 			);
138 138
 		}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 * @throws InvalidDataTypeException
147 147
 	 * @throws InvalidArgumentException
148 148
 	 */
149
-	protected function setBaseUrl( $base_url ) {
150
-		if ( ! is_string( $base_url ) ) {
151
-			throw new InvalidDataTypeException( '$base_url', $base_url, 'string' );
149
+	protected function setBaseUrl($base_url) {
150
+		if ( ! is_string($base_url)) {
151
+			throw new InvalidDataTypeException('$base_url', $base_url, 'string');
152 152
 		}
153
-		if ( empty( $base_url ) ) {
153
+		if (empty($base_url)) {
154 154
 			throw new InvalidArgumentException(
155
-				__( 'The base URL can not be an empty string.', 'event_espresso' )
155
+				__('The base URL can not be an empty string.', 'event_espresso')
156 156
 			);
157 157
 		}
158 158
 		$this->base_url = $base_url;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @throws InvalidDataTypeException
166 166
 	 */
167 167
 	public function formStepUrlKey() {
168
-		if ( empty( $this->form_step_url_key ) ) {
168
+		if (empty($this->form_step_url_key)) {
169 169
 			$this->setFormStepUrlKey();
170 170
 		}
171 171
 		return $this->form_step_url_key;
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param string $form_step_url_key
178 178
 	 * @throws InvalidDataTypeException
179 179
 	 */
180
-	public function setFormStepUrlKey( $form_step_url_key = 'ee-form-step' ) {
181
-		if ( ! is_string( $form_step_url_key ) ) {
182
-			throw new InvalidDataTypeException( '$form_step_key', $form_step_url_key, 'string' );
180
+	public function setFormStepUrlKey($form_step_url_key = 'ee-form-step') {
181
+		if ( ! is_string($form_step_url_key)) {
182
+			throw new InvalidDataTypeException('$form_step_key', $form_step_url_key, 'string');
183 183
 		}
184
-		$this->form_step_url_key = ! empty( $form_step_url_key ) ? $form_step_url_key : 'ee-form-step';
184
+		$this->form_step_url_key = ! empty($form_step_url_key) ? $form_step_url_key : 'ee-form-step';
185 185
 	}
186 186
 
187 187
 
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 * @param $default_form_step
200 200
 	 * @throws InvalidDataTypeException
201 201
 	 */
202
-	protected function setDefaultFormStep( $default_form_step ) {
203
-		if ( ! is_string( $default_form_step ) ) {
204
-			throw new InvalidDataTypeException( '$default_form_step', $default_form_step, 'string' );
202
+	protected function setDefaultFormStep($default_form_step) {
203
+		if ( ! is_string($default_form_step)) {
204
+			throw new InvalidDataTypeException('$default_form_step', $default_form_step, 'string');
205 205
 		}
206 206
 		$this->default_form_step = $default_form_step;
207 207
 	}
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @throws InvalidDataTypeException
215 215
 	 */
216 216
 	protected function setCurrentStepFromRequest() {
217
-		$current_step_slug = $this->request()->get( $this->formStepUrlKey(), $this->defaultFormStep() );
218
-		if ( ! $this->form_steps->setCurrent( $current_step_slug ) ) {
217
+		$current_step_slug = $this->request()->get($this->formStepUrlKey(), $this->defaultFormStep());
218
+		if ( ! $this->form_steps->setCurrent($current_step_slug)) {
219 219
 			throw new InvalidIdentifierException(
220 220
 				$current_step_slug,
221 221
 				$this->defaultFormStep(),
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
238 238
 	 */
239 239
 	public function getCurrentStep() {
240
-		if ( ! $this->form_steps->current() instanceof SequentialStepForm ) {
241
-			throw new InvalidFormHandlerException( $this->form_steps->current() );
240
+		if ( ! $this->form_steps->current() instanceof SequentialStepForm) {
241
+			throw new InvalidFormHandlerException($this->form_steps->current());
242 242
 		}
243 243
 		return $this->form_steps->current();
244 244
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
251 251
 	 */
252 252
 	public function formAction() {
253
-		if ( ! is_string( $this->form_action ) || empty( $this->form_action ) ) {
253
+		if ( ! is_string($this->form_action) || empty($this->form_action)) {
254 254
 			$this->form_action = $this->baseUrl();
255 255
 		}
256 256
 		return $this->form_action;
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 	 * @param string $form_action
263 263
 	 * @throws InvalidDataTypeException
264 264
 	 */
265
-	public function setFormAction( $form_action ) {
266
-		if ( ! is_string( $form_action ) ) {
267
-			throw new InvalidDataTypeException( '$form_action', $form_action, 'string' );
265
+	public function setFormAction($form_action) {
266
+		if ( ! is_string($form_action)) {
267
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
268 268
 		}
269 269
 		$this->form_action = $form_action;
270 270
 	}
@@ -275,15 +275,15 @@  discard block
 block discarded – undo
275 275
 	 * @param array $form_action_args
276 276
 	 * @throws InvalidDataTypeException
277 277
 	 */
278
-	public function addFormActionArgs( $form_action_args = array() ) {
279
-		if ( ! is_array( $form_action_args ) ) {
280
-			throw new InvalidDataTypeException( '$form_action_args', $form_action_args, 'array' );
278
+	public function addFormActionArgs($form_action_args = array()) {
279
+		if ( ! is_array($form_action_args)) {
280
+			throw new InvalidDataTypeException('$form_action_args', $form_action_args, 'array');
281 281
 		}
282
-		$form_action_args = ! empty( $form_action_args )
282
+		$form_action_args = ! empty($form_action_args)
283 283
 			? $form_action_args
284
-			: array( $this->formStepUrlKey() => $this->form_steps->current()->slug() );
284
+			: array($this->formStepUrlKey() => $this->form_steps->current()->slug());
285 285
 		$this->getCurrentStep()->setFormAction(
286
-			add_query_arg( $form_action_args, $this->formAction() )
286
+			add_query_arg($form_action_args, $this->formAction())
287 287
 		);
288 288
 		$this->form_action = $this->getCurrentStep()->formAction();
289 289
 	}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	/**
303 303
 	 * @param string $form_config
304 304
 	 */
305
-	public function setFormConfig( $form_config ) {
305
+	public function setFormConfig($form_config) {
306 306
 		$this->form_config = $form_config;
307 307
 	}
308 308
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	/**
321 321
 	 * @param string $progress_step_style
322 322
 	 */
323
-	public function setProgressStepStyle( $progress_step_style ) {
323
+	public function setProgressStepStyle($progress_step_style) {
324 324
 		$this->progress_step_style = $progress_step_style;
325 325
 	}
326 326
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 */
341 341
 	protected function getProgressStepsCollection() {
342 342
 		static $collection = null;
343
-		if ( ! $collection instanceof ProgressStepCollection ) {
343
+		if ( ! $collection instanceof ProgressStepCollection) {
344 344
 			$collection = new ProgressStepCollection();
345 345
 		}
346 346
 		return $collection;
@@ -356,12 +356,12 @@  discard block
 block discarded – undo
356 356
 	 * @throws InvalidClassException
357 357
 	 * @throws InvalidInterfaceException
358 358
 	 */
359
-	protected function generateProgressSteps( Collection $progress_steps_collection ) {
359
+	protected function generateProgressSteps(Collection $progress_steps_collection) {
360 360
 		$current_step = $this->getCurrentStep();
361 361
 		/** @var SequentialStepForm $form_step */
362
-		foreach ( $this->form_steps as $form_step ) {
362
+		foreach ($this->form_steps as $form_step) {
363 363
 			// is this step active ?
364
-			if ( ! $form_step->initialize() ) {
364
+			if ( ! $form_step->initialize()) {
365 365
 				continue;
366 366
 			}
367 367
 			$progress_steps_collection->add(
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 			);
376 376
 		}
377 377
 		// set collection pointer back to current step
378
-		$this->form_steps->setCurrentUsingObject( $current_step );
378
+		$this->form_steps->setCurrentUsingObject($current_step);
379 379
 		return new ProgressStepManager(
380 380
 			$this->progressStepStyle(),
381 381
 			$this->defaultFormStep(),
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 	 * @throws InvalidInterfaceException
410 410
 	 * @throws InvalidArgumentException
411 411
 	 */
412
-	public function processForm( $form_data = array() ) {
412
+	public function processForm($form_data = array()) {
413 413
 		$this->buildCurrentStepFormForProcessing();
414
-		$this->processCurrentStepForm( $form_data );
414
+		$this->processCurrentStepForm($form_data);
415 415
 	}
416 416
 
417 417
 
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 	public function buildCurrentStepFormForDisplay() {
428 428
 		$form_step = $this->buildCurrentStepForm();
429 429
 		// no displayable content ? then skip straight to processing
430
-		if ( ! $form_step->displayable() ) {
430
+		if ( ! $form_step->displayable()) {
431 431
 			$this->addFormActionArgs();
432
-			$form_step->setFormAction( $this->formAction() );
433
-			wp_safe_redirect( $form_step->formAction() );
432
+			$form_step->setFormAction($this->formAction());
433
+			wp_safe_redirect($form_step->formAction());
434 434
 		}
435 435
 	}
436 436
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @throws InvalidArgumentException
446 446
 	 */
447 447
 	public function buildCurrentStepFormForProcessing() {
448
-		$this->buildCurrentStepForm( false );
448
+		$this->buildCurrentStepForm(false);
449 449
 	}
450 450
 
451 451
 
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
 	 * @throws InvalidInterfaceException
461 461
 	 * @throws InvalidArgumentException
462 462
 	 */
463
-	private function buildCurrentStepForm( $for_display = true ) {
463
+	private function buildCurrentStepForm($for_display = true) {
464 464
 		$this->form_steps = $this->getFormStepsCollection();
465 465
 		$this->setCurrentStepFromRequest();
466 466
 		$form_step = $this->getCurrentStep();
467
-		if ( $form_step->submitBtnText() === __( 'Submit', 'event_espresso' ) ) {
468
-			$form_step->setSubmitBtnText( __( 'Next Step', 'event_espresso' ) );
467
+		if ($form_step->submitBtnText() === __('Submit', 'event_espresso')) {
468
+			$form_step->setSubmitBtnText(__('Next Step', 'event_espresso'));
469 469
 		}
470
-		if ( $for_display && $form_step->displayable() ) {
470
+		if ($for_display && $form_step->displayable()) {
471 471
 			$this->progress_step_manager = $this->generateProgressSteps(
472 472
 				$this->getProgressStepsCollection()
473 473
 			);
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
 			$this->progress_step_manager->setPreviousStepsCompleted();
479 479
 			$this->progress_step_manager->enqueueStylesAndScripts();
480 480
 			$this->addFormActionArgs();
481
-			$form_step->setFormAction( $this->formAction() );
481
+			$form_step->setFormAction($this->formAction());
482 482
 
483 483
 		} else {
484
-			$form_step->setRedirectUrl( $this->baseUrl() );
484
+			$form_step->setRedirectUrl($this->baseUrl());
485 485
 			$form_step->addRedirectArgs(
486
-				array( $this->formStepUrlKey() => $this->form_steps->current()->slug() )
486
+				array($this->formStepUrlKey() => $this->form_steps->current()->slug())
487 487
 			);
488 488
 		}
489 489
 		$form_step->generate();
490
-		if ( $for_display ) {
490
+		if ($for_display) {
491 491
 			$form_step->enqueueStylesAndScripts();
492 492
 		}
493 493
 		return $form_step;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @param bool $return_as_string
500 500
 	 * @return string
501 501
 	 */
502
-	public function displayProgressSteps( $return_as_string = true ) {
502
+	public function displayProgressSteps($return_as_string = true) {
503 503
 		$progress_steps = apply_filters(
504 504
 			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__before_steps',
505 505
 			''
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_SequentialStepFormManager__displayProgressSteps__after_steps',
510 510
 			''
511 511
 		);
512
-		if ( $return_as_string ) {
512
+		if ($return_as_string) {
513 513
 			return $progress_steps;
514 514
 		}
515 515
 		echo $progress_steps;
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	 * @return string
524 524
 	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
525 525
 	 */
526
-	public function displayCurrentStepForm( $return_as_string = true ) {
527
-		if ( $return_as_string ) {
526
+	public function displayCurrentStepForm($return_as_string = true) {
527
+		if ($return_as_string) {
528 528
 			return $this->getCurrentStep()->display();
529 529
 		}
530 530
 		echo $this->getCurrentStep()->display();
@@ -539,32 +539,32 @@  discard block
 block discarded – undo
539 539
 	 * @throws InvalidArgumentException
540 540
 	 * @throws InvalidDataTypeException
541 541
 	 */
542
-	public function processCurrentStepForm( $form_data = array() ) {
542
+	public function processCurrentStepForm($form_data = array()) {
543 543
 		// grab instance of current step because after calling next() below,
544 544
 		// any calls to getCurrentStep() will return the "next" step because we advanced
545 545
 		$current_step = $this->getCurrentStep();
546 546
 		try {
547 547
 			// form processing should either throw exceptions or return true
548
-			$current_step->process( $form_data );
549
-		} catch ( Exception $e ) {
548
+			$current_step->process($form_data);
549
+		} catch (Exception $e) {
550 550
 			// something went wrong, so...
551 551
 			// if WP_DEBUG === true, display the Exception and stack trace right now
552
-			new ExceptionStackTraceDisplay( $e );
552
+			new ExceptionStackTraceDisplay($e);
553 553
 			// else convert the Exception to an EE_Error
554
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
554
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
555 555
 			// prevent redirect to next step or other if exception was thrown
556 556
 			if (
557 557
 				$current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_NEXT_STEP
558 558
 				|| $current_step->redirectTo() === SequentialStepForm::REDIRECT_TO_OTHER
559 559
 			) {
560
-				$current_step->setRedirectTo( SequentialStepForm::REDIRECT_TO_CURRENT_STEP );
560
+				$current_step->setRedirectTo(SequentialStepForm::REDIRECT_TO_CURRENT_STEP);
561 561
 			}
562 562
 		}
563 563
 		// save notices to a transient so that when we redirect back
564 564
 		// to the display portion for this step
565 565
 		// those notices can be displayed
566
-		EE_Error::get_notices( false, true );
567
-		$this->redirectForm( $current_step );
566
+		EE_Error::get_notices(false, true);
567
+		$this->redirectForm($current_step);
568 568
 	}
569 569
 
570 570
 
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 	 *
575 575
 	 * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepFormInterface $current_step
576 576
 	 */
577
-	public function redirectForm( SequentialStepFormInterface $current_step ) {
577
+	public function redirectForm(SequentialStepFormInterface $current_step) {
578 578
 		$redirect_step = $current_step;
579
-		switch( $current_step->redirectTo() ) {
579
+		switch ($current_step->redirectTo()) {
580 580
 
581 581
 			case SequentialStepForm::REDIRECT_TO_OTHER :
582 582
 				// going somewhere else, so just check out now
583
-				wp_safe_redirect( $redirect_step->redirectUrl() );
583
+				wp_safe_redirect($redirect_step->redirectUrl());
584 584
 				exit();
585 585
 				break;
586 586
 
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
 			case SequentialStepForm::REDIRECT_TO_NEXT_STEP :
592 592
 				$this->form_steps->next();
593
-				if ( $this->form_steps->valid() ) {
593
+				if ($this->form_steps->valid()) {
594 594
 					$redirect_step = $this->form_steps->current();
595 595
 				}
596 596
 				break;
@@ -600,12 +600,12 @@  discard block
 block discarded – undo
600 600
 				// $redirect_step is already set
601 601
 
602 602
 		}
603
-		$current_step->setRedirectUrl( $this->baseUrl() );
603
+		$current_step->setRedirectUrl($this->baseUrl());
604 604
 		$current_step->addRedirectArgs(
605 605
 			// use the slug for whatever step we are redirecting too
606
-			array( $this->formStepUrlKey() => $redirect_step->slug() )
606
+			array($this->formStepUrlKey() => $redirect_step->slug())
607 607
 		);
608
-		wp_safe_redirect( $current_step->redirectUrl() );
608
+		wp_safe_redirect($current_step->redirectUrl());
609 609
 		exit();
610 610
 	}
611 611
 
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Select_Ajax_Model_Rest_Input.input.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @subpackage
12 12
  * @author				Mike Nelson
13 13
  */
14
-class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base{
14
+class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base {
15 15
 
16 16
 	/**
17 17
 	 * @var string $_model_name
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *                                  And the arguments accepted by EE_Form_Input_With_Options_Base
51 51
 	 * @throws \EE_Error
52 52
 	 */
53
-	public function __construct( $input_settings = array() ) {
53
+	public function __construct($input_settings = array()) {
54 54
 		//needed input settings:
55 55
 		//select2_args
56 56
 		$this->_model_name = EEH_Array::is_set(
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$query_params = EEH_Array::is_set(
63 63
 			$input_settings,
64 64
 			'query_params',
65
-			array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin )
65
+			array('limit' => 10, 'caps' => EEM_Base::caps_read_admin)
66 66
 		);
67 67
 		$this->_value_field_name = EEH_Array::is_set(
68 68
 			$input_settings,
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$this->_display_field_name = EEH_Array::is_set(
73 73
 			$input_settings,
74 74
 			'display_field_name',
75
-			$model->get_a_field_of_type( 'EE_Text_Field_Base' )->get_name()
75
+			$model->get_a_field_of_type('EE_Text_Field_Base')->get_name()
76 76
 		);
77 77
 		$this->_select_columns = EEH_Array::is_set(
78 78
 			$input_settings,
@@ -89,27 +89,27 @@  discard block
 block discarded – undo
89 89
 		);
90 90
 		//get resource endpoint
91 91
 		$rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read();
92
-		$rest_controller->set_requested_version( EED_Core_Rest_Api::latest_rest_api_version() );
92
+		$rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version());
93 93
 		$default_select2_args = array(
94 94
 			'ajax' => array(
95 95
 				'url' => $rest_controller->get_versioned_link_to(
96 96
 					EEH_Array::is_set(
97 97
 						$input_settings,
98 98
 						'endpoint',
99
-						EEH_Inflector::pluralize_and_lower( $this->_model_name )
99
+						EEH_Inflector::pluralize_and_lower($this->_model_name)
100 100
 					)
101 101
 				),
102 102
 				'dataType' => 'json',
103 103
 				'delay' => '250',
104 104
 				'data_interface' => 'EE_Select2_REST_API_Interface',
105 105
 				'data_interface_args' => array(
106
-					'default_query_params' => (object)Model_Data_Translator::prepare_query_params_for_rest_api(
106
+					'default_query_params' => (object) Model_Data_Translator::prepare_query_params_for_rest_api(
107 107
 						$query_params,
108 108
 						$model
109 109
 					),
110 110
 					'display_field' => $this->_display_field_name,
111 111
 					'value_field' => $this->_value_field_name,
112
-					'nonce' => wp_create_nonce( 'wp_rest' )
112
+					'nonce' => wp_create_nonce('wp_rest')
113 113
 				),
114 114
 			),
115 115
 			'cache' => true,
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		);
118 118
 		$select2_args = array_replace_recursive(
119 119
 			$default_select2_args,
120
-			(array)EEH_Array::is_set( $input_settings, 'select2_args', array() )
120
+			(array) EEH_Array::is_set($input_settings, 'select2_args', array())
121 121
 		);
122
-		$this->set_display_strategy( new EE_Select2_Display_Strategy( $select2_args ) );
123
-		parent::__construct( array(), $input_settings );
122
+		$this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args));
123
+		parent::__construct(array(), $input_settings);
124 124
 	}
125 125
 
126 126
 
@@ -138,34 +138,34 @@  discard block
 block discarded – undo
138 138
 	 * @return void
139 139
 	 * @throws \EE_Error
140 140
 	 */
141
-	public function _set_raw_value( $value ) {
142
-		$values_for_options = (array)$value;
143
-		$value_field = $this->_get_model()->field_settings_for( $this->_value_field_name );
144
-		$display_field = $this->_get_model()->field_settings_for( $this->_display_field_name );
145
-		$this->_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name;
146
-		$this->_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name;
141
+	public function _set_raw_value($value) {
142
+		$values_for_options = (array) $value;
143
+		$value_field = $this->_get_model()->field_settings_for($this->_value_field_name);
144
+		$display_field = $this->_get_model()->field_settings_for($this->_display_field_name);
145
+		$this->_select_columns[] = $value_field->get_qualified_column().' AS '.$this->_value_field_name;
146
+		$this->_select_columns[] = $display_field->get_qualified_column().' AS '.$this->_display_field_name;
147 147
 		$display_values = $this->_get_model()->get_all_wpdb_results(
148 148
 			array(
149 149
 				array(
150
-					$this->_value_field_name => array( 'IN', $values_for_options )
150
+					$this->_value_field_name => array('IN', $values_for_options)
151 151
 				)
152 152
 			),
153 153
 			ARRAY_A,
154
-			implode( ',', $this->_select_columns )
154
+			implode(',', $this->_select_columns)
155 155
 		);
156 156
 		$select_options = array();
157
-		if( is_array( $select_options ) ) {
158
-			foreach( $display_values as $db_rows ) {
159
-				$db_rows = (array)$db_rows;
160
-				$select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters(
157
+		if (is_array($select_options)) {
158
+			foreach ($display_values as $db_rows) {
159
+				$db_rows = (array) $db_rows;
160
+				$select_options[$db_rows[$this->_value_field_name]] = apply_filters(
161 161
 					'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value',
162
-					$db_rows[ $this->_display_field_name ],
162
+					$db_rows[$this->_display_field_name],
163 163
 					$db_rows
164 164
 				);
165 165
 			}
166 166
 		}
167
-		$this->set_select_options( $select_options );
168
-		parent::_set_raw_value( $value );
167
+		$this->set_select_options($select_options);
168
+		parent::_set_raw_value($value);
169 169
 	}
170 170
 
171 171
 	/**
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @throws EE_Error
175 175
 	 */
176 176
 	protected function _get_model() {
177
-		if( ! EE_Registry::instance()->is_model_name(  $this->_model_name ) ) {
177
+		if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) {
178 178
 			throw new EE_Error(
179 179
 				sprintf(
180 180
 					__(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				)
186 186
 			);
187 187
 		} else {
188
-			return EE_Registry::instance()->load_model( $this->_model_name );
188
+			return EE_Registry::instance()->load_model($this->_model_name);
189 189
 		}
190 190
 	}
191 191
 
Please login to merge, or discard this patch.