WC_REST_Data_Controller::prepare_item_for_response()
Prepare a data resource object for serialization.
Метод класса: WC_REST_Data_Controller{}
Хуков нет.
Возвращает
WP_REST_Response
. $response Response data.
Использование
$WC_REST_Data_Controller = new WC_REST_Data_Controller(); $WC_REST_Data_Controller->prepare_item_for_response( $resource, $request );
- $resource(stdClass) (обязательный)
- Resource data.
- $request(WP_REST_Request) (обязательный)
- Request object.
Код WC_REST_Data_Controller::prepare_item_for_response() WC REST Data Controller::prepare item for response WC 9.2.3
public function prepare_item_for_response( $resource, $request ) { $data = array( 'slug' => $resource->slug, 'description' => $resource->description, ); $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, 'view' ); // Wrap the data in a response object. $response = rest_ensure_response( $data ); $response->add_links( $this->prepare_links( $resource ) ); return $response; }