BP_REST_Friends_Endpoint::prepare_item_for_response( BP_Friends_Friendship $friendship, WP_REST_Request $request )
Prepares friendship data to return as an object.
Description
Parameters
- $friendship
-
(Required) Friendship object.
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response)
Source
File: bp-friends/classes/class-bp-rest-friends-endpoint.php
public function prepare_item_for_response( $friendship, $request ) { $data = array( 'id' => $friendship->id, 'initiator_id' => $friendship->initiator_user_id, 'friend_id' => $friendship->friend_user_id, 'is_confirmed' => (bool) $friendship->is_confirmed, 'date_created' => bp_rest_prepare_date_response( $friendship->date_created ), ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); /** * Filter a friendship value returned from the API. * * @param WP_REST_Response $response Response generated by the request. * @param WP_REST_Request $request Request used to generate the response. * @param BP_Friends_Friendship $friendship The friendship object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_friends_prepare_value', $response, $request, $friendship ); }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.