Skip to content

Commit

Permalink
Feat: Make donation list table extendable
Browse files Browse the repository at this point in the history
  • Loading branch information
David GABISON committed Dec 18, 2023
1 parent 584621b commit ef9e57f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Donations/Endpoints/ListDonations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -217,7 +229,7 @@ public function getTotalDonationsCount(): int
*
* @return array{0: QueryBuilder, 1: array<DonationMetaKeys>}
*/
private function getWhereConditions(QueryBuilder $query): array
protected function getWhereConditions(QueryBuilder $query): array
{
$search = $this->request->get_param('search');
$start = $this->request->get_param('start');
Expand Down

0 comments on commit ef9e57f

Please sign in to comment.