WC_CLI_REST_Command::get_context_fields()privateWC 1.0

Get a list of fields present in a given context

Method of the class: WC_CLI_REST_Command{}

No Hooks.

Return

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_context_fields( $context );
$context(string) (required)
Scope under which the request is made. Determines fields present in response.

WC_CLI_REST_Command::get_context_fields() code WC 8.6.1

private function get_context_fields( $context ) {
	$fields = array();
	foreach ( $this->schema['properties'] as $key => $args ) {
		if ( empty( $args['context'] ) || in_array( $context, $args['context'], true ) ) {
			$fields[] = $key;
		}
	}
	return $fields;
}