WC_CLI_REST_Command::get_formatter()
Get Formatter object based on supplied parameters.
Method of the class: WC_CLI_REST_Command{}
No Hooks.
Return
\WP_CLI\Formatter
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_formatter( $assoc_args );
- $assoc_args(array) (required) (passed by reference — &)
- Parameters passed to command. Determines formatting.
WC_CLI_REST_Command::get_formatter() WC CLI REST Command::get formatter code WC 9.8.1
protected function get_formatter( &$assoc_args ) { if ( ! empty( $assoc_args['fields'] ) ) { if ( is_string( $assoc_args['fields'] ) ) { $fields = explode( ',', $assoc_args['fields'] ); } else { $fields = $assoc_args['fields']; } } else { if ( ! empty( $assoc_args['context'] ) ) { $fields = $this->get_context_fields( $assoc_args['context'] ); } else { $fields = $this->get_context_fields( 'view' ); } } return new \WP_CLI\Formatter( $assoc_args, $fields ); }