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