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