Command::get_item( $args, $assoc_args )
Get a single item.
Contents
Source Source
File: libraries/lifterlms-cli/src/Commands/Restful/Command.php
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | 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