Skip to content

Commit

Permalink
refactor: use container dependency injection
Browse files Browse the repository at this point in the history
following @kjohnson instructions
  • Loading branch information
David GABISON committed Dec 18, 2023
1 parent ef9e57f commit 8748f35
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/Donations/Endpoints/ListDonations.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
use WP_REST_Request;
use WP_REST_Response;

/**
* @unreleased The class is extendable
*/
class ListDonations extends Endpoint
{
/**
Expand All @@ -29,6 +32,15 @@ class ListDonations extends Endpoint
*/
protected $listTable;

/**
* @unreleased
* @access public
*/
public function __construct(DonationsListTable $listTable)
{
$this->listTable = $listTable;
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -119,7 +131,6 @@ 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 @@ -130,7 +141,6 @@ public function registerRoute()
*/
public function handleRequest(WP_REST_Request $request): WP_REST_Response
{
$this->init();
$this->request = $request;

$donations = $this->getDonations();
Expand All @@ -153,16 +163,6 @@ 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 @@ -220,7 +220,6 @@ 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 Down

0 comments on commit 8748f35

Please sign in to comment.