RestAPI.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\ServiceProviders; |
| 4 | |
| 5 | use Give\API\Endpoints\Reports\AverageDonation; |
| 6 | use Give\API\Endpoints\Reports\FormPerformance; |
| 7 | use Give\API\Endpoints\Reports\Income; |
| 8 | use Give\API\Endpoints\Reports\IncomeBreakdown; |
| 9 | use Give\API\Endpoints\Reports\PaymentMethods; |
| 10 | use Give\API\Endpoints\Reports\PaymentStatuses; |
| 11 | use Give\API\Endpoints\Reports\RecentDonations; |
| 12 | use Give\API\Endpoints\Reports\TopDonors; |
| 13 | use Give\API\Endpoints\Reports\TotalDonors; |
| 14 | use Give\API\Endpoints\Reports\TotalIncome; |
| 15 | use Give\API\Endpoints\Reports\TotalRefunds; |
| 16 | use Give\API\RestRoute; |
| 17 | |
| 18 | class RestAPI implements ServiceProvider { |
| 19 | /** |
| 20 | * @var string[] array of RestRoute classes |
| 21 | */ |
| 22 | private $reportRoutes = [ |
| 23 | PaymentStatuses::class, |
| 24 | PaymentMethods::class, |
| 25 | FormPerformance::class, |
| 26 | TopDonors::class, |
| 27 | RecentDonations::class, |
| 28 | Income::class, |
| 29 | IncomeBreakdown::class, |
| 30 | AverageDonation::class, |
| 31 | TotalDonors::class, |
| 32 | TotalIncome::class, |
| 33 | TotalRefunds::class, |
| 34 | ]; |
| 35 | |
| 36 | /** |
| 37 | * @inheritDoc |
| 38 | */ |
| 39 | public function register() { |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @inheritDoc |
| 44 | */ |
| 45 | public function boot() { |
| 46 | add_action( 'rest_api_init', [ $this, 'registerRoutes' ] ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Calls the route registrations within the WordPress REST API hook |
| 51 | * |
| 52 | * @since 2.8.0 |
| 53 | */ |
| 54 | public function registerRoutes() { |
| 55 | foreach ( $this->reportRoutes as $route ) { |
| 56 | /** @var RestRoute $route */ |
| 57 | $route = give()->make( $route ); |
| 58 | |
| 59 | $route->registerRoute(); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 |