Skip to content

Commit

Permalink
refactor: merge v3 service providers into existing ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Waldstein committed Aug 15, 2023
1 parent a7f18ee commit 7aa1d2a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 70 deletions.
7 changes: 3 additions & 4 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,10 @@ final class Give
DonationFormsServiceProvider::class,
FormDesignServiceProvider::class,
FormMigrationServiceProvider::class,
//TODO merge this service providers
//TODO: merge this service provider
Give\PaymentGateways\Gateways\ServiceProvider::class,
//TODO: this was the beta welcome banner, remove this?
Give\Promotions\ServiceProviderV3::class,
Give\Donations\ServiceProviderV3::class,
Give\Donors\ServiceProviderV3::class,
Give\PaymentGateways\Gateways\ServiceProvider::class

];

Expand Down
12 changes: 12 additions & 0 deletions src/Donations/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Give\Donations;

use Give\Donations\CustomFields\Controllers\DonationDetailsController;
use Give\Donations\LegacyListeners\ClearDonationPostCache;
use Give\Donations\LegacyListeners\DispatchDonationNoteEmailNotification;
use Give\Donations\LegacyListeners\DispatchGiveInsertPayment;
Expand Down Expand Up @@ -46,6 +47,7 @@ public function boot()
{
$this->bootLegacyListeners();
$this->registerDonationsAdminPage();
$this->addCustomFieldsToDonationDetails();

give(MigrationsRegister::class)->addMigrations([
AddMissingDonorIdToDonationComments::class,
Expand Down Expand Up @@ -115,4 +117,14 @@ private function registerDonationsAdminPage()
}
}
}

/**
* @since 3.0.0
*/
private function addCustomFieldsToDonationDetails()
{
add_action('give_view_donation_details_billing_after', static function ($donationId) {
echo (new DonationDetailsController())->show($donationId);
});
}
}
29 changes: 0 additions & 29 deletions src/Donations/ServiceProviderV3.php

This file was deleted.

18 changes: 18 additions & 0 deletions src/Donors/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace Give\Donors;

use Give\Donors\CustomFields\Controllers\DonorDetailsController;
use Give\Donors\ListTable\DonorsListTable;
use Give\Donors\Models\Donor;
use Give\Donors\Repositories\DonorRepositoryProxy;
use Give\Helpers\Hooks;
use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface;
use Give_Donor as LegacyDonor;

/**
* @since 2.19.6
Expand Down Expand Up @@ -46,5 +49,20 @@ public function boot()
{
Hooks::addAction( 'admin_head', DonorsAdminPage::class, 'renderReactSwitch');
}

$this->addCustomFieldsToDonorDetails();
}

/**
* @since 3.0.0
*/
private function addCustomFieldsToDonorDetails()
{
add_action('give_donor_after_tables', static function (LegacyDonor $legacyDonor) {
/** @var Donor $donor */
$donor = Donor::find($legacyDonor->id);

echo (new DonorDetailsController())->show($donor);
});
}
}
35 changes: 0 additions & 35 deletions src/Donors/ServiceProviderV3.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Promotions/ServiceProviderV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function register()
*/
public function boot()
{
if(!get_option('givewp_next_gen_welcome_banner_dismissed')) {
if (!get_option('givewp_next_gen_welcome_banner_dismissed')) {
Hooks::addAction('admin_notices', \Give\Promotions\WelcomeBanner\Actions\DisplayWelcomeBanner::class);
Hooks::addAction('wp_ajax_givewp_next_gen_welcome_banner_dismiss', \Give\Promotions\WelcomeBanner\Actions\DismissWelcomeBanner::class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Give\Promotions\WelcomeBanner\Actions;

use Give\Addon\View;
use Give\Framework\Views\View;

class DisplayWelcomeBanner
{
Expand Down

0 comments on commit 7aa1d2a

Please sign in to comment.