Command::get_item( $args, $assoc_args )
Get a single item.
Contents
Source Source
File: libraries/lifterlms-cli/src/Commands/Restful/Command.php
public function get_item( $args, $assoc_args ) { list( $status, $body, $headers ) = $this->do_request( 'GET', $this->get_filled_route( $args ), $assoc_args ); if ( ! empty( $assoc_args['fields'] ) ) { $body = self::limit_item_to_fields( $body, $fields ); } if ( 'headers' === $assoc_args['format'] ) { echo json_encode( $headers ); } elseif ( 'body' === $assoc_args['format'] ) { echo json_encode( $body ); } elseif ( 'envelope' === $assoc_args['format'] ) { echo json_encode( array( 'body' => $body, 'headers' => $headers, 'status' => $status, 'api_url' => $this->api_url, ) ); } else { $formatter = $this->get_formatter( $assoc_args ); $formatter->display_item( $body ); } }
Expand full source code Collapse full source code View on GitHub