Completed
Pull Request — trunk (#541)
by Justin
06:40
created
includes/CMB2_REST_Controller_Fields.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 		$fields = array();
74 74
 		foreach ( $this->rest_box->cmb->prop( 'fields', array() ) as $field ) {
75
-			$field_id = $field['id'];
75
+			$field_id = $field[ 'id' ];
76 76
 			$rest_field = $this->get_rest_field( $field_id );
77 77
 
78 78
 			if ( ! is_wp_error( $rest_field ) ) {
79
-				$fields[ $field_id ] = $this->server->response_to_data( $rest_field, isset( $this->request['_embed'] ) );
79
+				$fields[ $field_id ] = $this->server->response_to_data( $rest_field, isset( $this->request[ '_embed' ] ) );
80 80
 			} else {
81 81
 				$fields[ $field_id ] = array( 'error' => $rest_field->get_error_message() );
82 82
 			}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	public function update_field_value( $request ) {
121 121
 		$this->initiate_rest_read_box( $request, 'field_value_update' );
122 122
 
123
-		if ( ! $this->request['value'] ) {
123
+		if ( ! $this->request[ 'value' ] ) {
124 124
 			return new WP_Error( 'cmb2_rest_update_field_error', __( 'CMB2 Field value cannot be updated without the value parameter specified.', 'cmb2' ), array( 'status' => 400 ) );
125 125
 		}
126 126
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function modify_field_value( $activity, $field ) {
158 158
 
159
-		if ( ! $this->request['object_id'] || ! $this->request['object_type'] ) {
159
+		if ( ! $this->request[ 'object_id' ] || ! $this->request[ 'object_type' ] ) {
160 160
 			return new WP_Error( 'cmb2_rest_modify_field_value_error', __( 'CMB2 Field value cannot be modified without the object_id and object_type parameters specified.', 'cmb2' ), array( 'status' => 400 ) );
161 161
 		}
162 162
 
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 			return new WP_Error( 'cmb2_rest_no_field_by_id_error', __( 'No field found by that id.', 'cmb2' ), array( 'status' => 403 ) );
169 169
 		}
170 170
 
171
-		$field->args["value_{$activity}"] = (bool) 'deleted' === $activity
171
+		$field->args[ "value_{$activity}" ] = (bool) 'deleted' === $activity
172 172
 			? $field->remove_data()
173
-			: $field->save_field( $this->request['value'] );
173
+			: $field->save_field( $this->request[ 'value' ] );
174 174
 
175 175
 		// If options page, save the $activity options
176
-		if ( 'options-page' == $this->request['object_type'] ) {
177
-			$field->args["value_{$activity}"] = cmb2_options( $this->request['object_id'] )->set();
176
+		if ( 'options-page' == $this->request[ 'object_type' ] ) {
177
+			$field->args[ "value_{$activity}" ] = cmb2_options( $this->request[ 'object_id' ] )->set();
178 178
 		}
179 179
 
180 180
 		$field_data = $this->get_rest_field( $field );
@@ -243,13 +243,13 @@  discard block
 block discarded – undo
243 243
 				$value = $field->options();
244 244
 			} elseif ( in_array( $key, CMB2_Field::$callable_fields, true ) ) {
245 245
 
246
-				if ( isset( $this->request['_rendered'] ) ) {
246
+				if ( isset( $this->request[ '_rendered' ] ) ) {
247 247
 					$value = $key === 'render_row_cb' ? $rendered : $field->get_param_callback_result( $key );
248 248
 				} elseif ( is_array( $value ) ) {
249 249
 					// We need to rewrite callbacks as string as they will cause
250 250
 					// JSON recursion errors.
251
-					$class = is_string( $value[0] ) ? $value[0] : get_class( $value[0] );
252
-					$value = $class . '::' . $value[1];
251
+					$class = is_string( $value[ 0 ] ) ? $value[ 0 ] : get_class( $value[ 0 ] );
252
+					$value = $class . '::' . $value[ 1 ];
253 253
 				}
254 254
 			}
255 255
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 			}
263 263
 		}
264 264
 
265
-		if ( $this->request['object_id'] && $this->request['object_type'] ) {
266
-			$field_data['value'] = $field->get_data();
265
+		if ( $this->request[ 'object_id' ] && $this->request[ 'object_type' ] ) {
266
+			$field_data[ 'value' ] = $field->get_data();
267 267
 		}
268 268
 
269 269
 		return $field_data;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 
297 297
 		// Don't embed boxes when looking at boxes route.
298 298
 		if ( '/cmb2/v1/boxes' !== CMB2_REST_Controller::get_intial_route() ) {
299
-			$links['up']['embeddable'] = true;
299
+			$links[ 'up' ][ 'embeddable' ] = true;
300 300
 		}
301 301
 
302 302
 		return $links;
Please login to merge, or discard this patch.