BP_REST_Components_Endpoint::prepare_item_for_response( array $component, WP_REST_Request $request )

Prepares component data for return as an object.


Description Description


Parameters Parameters

$component

(Required) The component and its values.

$request

(Required) Full details about the request.


Top ↑

Return Return

(WP_REST_Response)


Top ↑

Source Source

File: bp-core/classes/class-bp-rest-components-endpoint.php

	public function prepare_item_for_response( $component, $request ) {
		$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
		$data    = $this->add_additional_fields_to_object( $component, $request );
		$data    = $this->filter_response_by_context( $data, $context );

		// @todo add prepare_links
		$response = rest_ensure_response( $data );

		/**
		 * Filter a component value returned from the API.
		 *
		 * @since 5.0.0
		 *
		 * @param WP_REST_Response $response  The Response data.
		 * @param WP_REST_Request  $request   Request used to generate the response.
		 * @param array            $component The component and its values.
		 */
		return apply_filters( 'bp_rest_components_prepare_value', $response, $request, $component );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.