Refactor LocalAlternativePaymentMethodsModule

This commit is contained in:
Philipp Stracker 2024-08-29 18:52:38 +02:00
parent 5c6c3a0005
commit ac1e97e4e6
No known key found for this signature in database
2 changed files with 21 additions and 14 deletions

View file

@ -9,8 +9,6 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods; namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface; return static function (): LocalAlternativePaymentMethodsModule {
return static function (): ModuleInterface {
return new LocalAlternativePaymentMethodsModule(); return new LocalAlternativePaymentMethodsModule();
}; };

View file

@ -9,32 +9,39 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods; namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods;
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
use WC_Order; use WC_Order;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider; use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
/** /**
* Class LocalAlternativePaymentMethodsModule * Class LocalAlternativePaymentMethodsModule
*/ */
class LocalAlternativePaymentMethodsModule implements ModuleInterface { class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingModule, ExecutableModule {
use ModuleClassNameIdTrait;
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function setup(): ServiceProviderInterface { public function services() : array {
return new ServiceProvider( return require __DIR__ . '/../services.php';
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function run( ContainerInterface $c ): void { public function extensions() : array {
return require __DIR__ . '/../extensions.php';
}
/**
* {@inheritDoc}
*/
public function run( ContainerInterface $c ) : bool {
add_filter( add_filter(
'woocommerce_payment_gateways', 'woocommerce_payment_gateways',
/** /**
@ -150,6 +157,8 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
} }
} }
); );
return true;
} }
/** /**