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