Controllers
4 years ago
DataTransferObjects
3 years ago
Endpoints
3 years ago
Exceptions
4 years ago
Factories
3 years ago
Models
4 years ago
Repositories
3 years ago
ValueObjects
4 years ago
resources
3 years ago
DonorsAdminPage.php
4 years ago
ServiceProvider.php
4 years ago
ServiceProvider.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Donors; |
| 4 | |
| 5 | use Give\Donors\Repositories\DonorRepositoryProxy; |
| 6 | use Give\Helpers\Hooks; |
| 7 | use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; |
| 8 | |
| 9 | /** |
| 10 | * @since 2.19.6 |
| 11 | */ |
| 12 | class ServiceProvider implements ServiceProviderInterface |
| 13 | { |
| 14 | |
| 15 | /** |
| 16 | * @inheritDoc |
| 17 | */ |
| 18 | public function register() |
| 19 | { |
| 20 | give()->singleton('donors', DonorRepositoryProxy::class); |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * @inheritDoc |
| 25 | */ |
| 26 | public function boot() |
| 27 | { |
| 28 | $userId = get_current_user_id(); |
| 29 | $showLegacy = get_user_meta($userId, '_give_donors_archive_show_legacy', true); |
| 30 | // only register new admin page if user hasn't chosen to use the old one |
| 31 | if(empty($showLegacy)) { |
| 32 | Hooks::addAction('admin_menu', DonorsAdminPage::class, 'registerMenuItem'); |
| 33 | |
| 34 | if (DonorsAdminPage::isShowing()) { |
| 35 | Hooks::addAction('admin_enqueue_scripts', DonorsAdminPage::class, 'loadScripts'); |
| 36 | } |
| 37 | } |
| 38 | elseif(DonorsAdminPage::isShowing()) |
| 39 | { |
| 40 | Hooks::addAction( 'admin_head', DonorsAdminPage::class, 'renderReactSwitch'); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 |