From ef9e57fc56eedb3eef8b0c36a353583578f6271a Mon Sep 17 00:00:00 2001 From: David GABISON Date: Sun, 22 Oct 2023 20:18:46 +0200 Subject: [PATCH] Feat: Make donation list table extendable --- src/Donations/Endpoints/ListDonations.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Donations/Endpoints/ListDonations.php b/src/Donations/Endpoints/ListDonations.php index 96e75198585..f287e08f724 100644 --- a/src/Donations/Endpoints/ListDonations.php +++ b/src/Donations/Endpoints/ListDonations.php @@ -119,6 +119,7 @@ public function registerRoute() } /** + * @unreleased Make the class extendable * @since 2.24.0 Change this to use the new ListTable class * @since 2.20.0 * @@ -129,8 +130,8 @@ public function registerRoute() */ public function handleRequest(WP_REST_Request $request): WP_REST_Response { + $this->init(); $this->request = $request; - $this->listTable = give(DonationsListTable::class); $donations = $this->getDonations(); $donationsCount = $this->getTotalDonationsCount(); @@ -152,6 +153,16 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response ); } + /** + * Initialize which list table to use. + * + * @unreleased + */ + protected function init () + { + $this->listTable = give(DonationsListTable::class); + } + /** * @since 2.24.0 Replace Query Builder with Donations model * @since 2.21.0 @@ -209,6 +220,7 @@ public function getTotalDonationsCount(): int } /** + * @unreleased Make the class extendable * @since 3.2.0 Updated query to account for possible null and empty values for _give_payment_mode meta * @since 2.24.0 Remove joins as it uses ModelQueryBuilder and change clauses to use attach_meta * @since 2.21.0 @@ -217,7 +229,7 @@ public function getTotalDonationsCount(): int * * @return array{0: QueryBuilder, 1: array} */ - private function getWhereConditions(QueryBuilder $query): array + protected function getWhereConditions(QueryBuilder $query): array { $search = $this->request->get_param('search'); $start = $this->request->get_param('start');