WC_REST_CRUD_Controller::fetch_fields_using_getters()publicWC 1.0

Get fields for an object if getter is defined.

Метод класса: WC_REST_CRUD_Controller{}

Хуков нет.


Массив. Data fetched from getters.


$WC_REST_CRUD_Controller = new WC_REST_CRUD_Controller();
$WC_REST_CRUD_Controller->fetch_fields_using_getters( $object, $context, $fields );
$object(объект) (обязательный)
Object we are fetching response for.
$context(строка) (обязательный)
Context of the request. Can be view or edit.
$fields(массив) (обязательный)
List of fields to fetch.

Код WC_REST_CRUD_Controller::fetch_fields_using_getters() WC 8.1.1

public function fetch_fields_using_getters( $object, $context, $fields ) {
	$data = array();
	foreach ( $fields as $field ) {
		if ( method_exists( $this, "api_get_$field" ) ) {
			$data[ $field ] = $this->{"api_get_$field"}( $object, $context );
	return $data;