Files
4 years ago
Stats
1 year ago
Controller.php
1 year ago
DataStore.php
1 year ago
Query.php
1 year ago
Query.php
59 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class for parameter-based downloads report querying. |
| 4 | * |
| 5 | * Example usage: |
| 6 | * $args = array( |
| 7 | * 'before' => '2018-07-19 00:00:00', |
| 8 | * 'after' => '2018-07-05 00:00:00', |
| 9 | * 'page' => 2, |
| 10 | * 'products' => array(1,2,3) |
| 11 | * ); |
| 12 | * $report = new \Automattic\WooCommerce\Admin\API\Reports\Downloads\Query( $args ); |
| 13 | * $mydata = $report->get_data(); |
| 14 | */ |
| 15 | |
| 16 | namespace Automattic\WooCommerce\Admin\API\Reports\Downloads; |
| 17 | |
| 18 | defined( 'ABSPATH' ) || exit; |
| 19 | |
| 20 | use Automattic\WooCommerce\Admin\API\Reports\Query as ReportsQuery; |
| 21 | |
| 22 | /** |
| 23 | * API\Reports\Downloads\Query |
| 24 | * |
| 25 | * @deprecated 9.3.0 Downloads\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly. |
| 26 | */ |
| 27 | class Query extends ReportsQuery { |
| 28 | |
| 29 | /** |
| 30 | * Valid fields for downloads report. |
| 31 | * |
| 32 | * @deprecated 9.3.0 Downloads\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly. |
| 33 | * |
| 34 | * @return array |
| 35 | */ |
| 36 | protected function get_default_query_vars() { |
| 37 | wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' ); |
| 38 | |
| 39 | return array(); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get downloads data based on the current query vars. |
| 44 | * |
| 45 | * @deprecated 9.3.0 Downloads\Query class is deprecated. Please use `GenericQuery`, \WC_Object_Query`, or use `DataStore` directly. |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | public function get_data() { |
| 50 | wc_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '9.3.0', '`GenericQuery`, `\WC_Object_Query`, or direct `DataStore` use' ); |
| 51 | |
| 52 | $args = apply_filters( 'woocommerce_analytics_downloads_query_args', $this->get_query_vars() ); |
| 53 | |
| 54 | $data_store = \WC_Data_Store::load( 'report-downloads' ); |
| 55 | $results = $data_store->get_data( $args ); |
| 56 | return apply_filters( 'woocommerce_analytics_downloads_select_query', $results, $args ); |
| 57 | } |
| 58 | } |
| 59 |