DataTransferObjects
4 years ago
Factories
4 years ago
LegacyListeners
4 years ago
Migrations
4 years ago
Models
4 years ago
Repositories
4 years ago
ValueObjects
4 years ago
ServiceProvider.php
4 years ago
ServiceProvider.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Subscriptions; |
| 4 | |
| 5 | use Give\Framework\Migrations\MigrationsRegister; |
| 6 | use Give\Helpers\Hooks; |
| 7 | use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; |
| 8 | use Give\Subscriptions\LegacyListeners\DispatchGiveSubscriptionPostCreate; |
| 9 | use Give\Subscriptions\LegacyListeners\DispatchGiveSubscriptionPreCreate; |
| 10 | use Give\Subscriptions\Migrations\CreateSubscriptionTables; |
| 11 | use Give\Subscriptions\Repositories\SubscriptionRepository; |
| 12 | |
| 13 | class ServiceProvider implements ServiceProviderInterface |
| 14 | { |
| 15 | /** |
| 16 | * @inheritDoc |
| 17 | */ |
| 18 | public function register() |
| 19 | { |
| 20 | give()->singleton('subscriptions', SubscriptionRepository::class); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @inheritDoc |
| 25 | */ |
| 26 | public function boot() |
| 27 | { |
| 28 | $this->bootLegacyListeners(); |
| 29 | |
| 30 | give(MigrationsRegister::class)->addMigration(CreateSubscriptionTables::class); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Legacy Listeners |
| 35 | * |
| 36 | * @since 2.19.6 |
| 37 | */ |
| 38 | private function bootLegacyListeners() |
| 39 | { |
| 40 | Hooks::addAction('give_subscription_creating', DispatchGiveSubscriptionPreCreate::class); |
| 41 | Hooks::addAction('give_subscription_created', DispatchGiveSubscriptionPostCreate::class); |
| 42 | } |
| 43 | } |
| 44 |