Migrations
5 years ago
Repositories
5 years ago
DonationHandler.php
5 years ago
RevenueServiceProvider.php
5 years ago
RevenueServiceProvider.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Revenue; |
| 4 | |
| 5 | use Give\Framework\Migrations\MigrationsRegister; |
| 6 | use Give\Helpers\Hooks; |
| 7 | use Give\Revenue\Migrations\AddPastDonationsToRevenueTable; |
| 8 | use Give\Revenue\Migrations\CreateRevenueTable; |
| 9 | use Give\ServiceProviders\ServiceProvider; |
| 10 | |
| 11 | class RevenueServiceProvider implements ServiceProvider { |
| 12 | /** |
| 13 | * @inheritDoc |
| 14 | * |
| 15 | * @since 2.9.0 |
| 16 | */ |
| 17 | public function register() { |
| 18 | global $wpdb; |
| 19 | |
| 20 | $wpdb->give_revenue = "{$wpdb->prefix}give_revenue"; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @inheritDoc |
| 25 | * |
| 26 | * @since 2.9.0 |
| 27 | */ |
| 28 | public function boot() { |
| 29 | $this->registerMigrations(); |
| 30 | |
| 31 | Hooks::addAction( 'give_insert_payment', DonationHandler::class, 'handle', 999, 1 ); |
| 32 | Hooks::addAction( 'give_register_updates', AddPastDonationsToRevenueTable::class, 'register' ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Registers database migrations with the MigrationsRunner |
| 37 | */ |
| 38 | private function registerMigrations() { |
| 39 | /** @var MigrationsRegister $register */ |
| 40 | $register = give( MigrationsRegister::class ); |
| 41 | |
| 42 | $register->addMigration( CreateRevenueTable::class ); |
| 43 | } |
| 44 | } |
| 45 |