From ac1e97e4e6152534b8be88098a2fbadbef009a09 Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Thu, 29 Aug 2024 18:52:38 +0200 Subject: [PATCH] Refactor LocalAlternativePaymentMethodsModule --- .../module.php | 4 +-- .../LocalAlternativePaymentMethodsModule.php | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/modules/ppcp-local-alternative-payment-methods/module.php b/modules/ppcp-local-alternative-payment-methods/module.php index 9b69c59b1..ef3a095f8 100644 --- a/modules/ppcp-local-alternative-payment-methods/module.php +++ b/modules/ppcp-local-alternative-payment-methods/module.php @@ -9,8 +9,6 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods; -use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface; - -return static function (): ModuleInterface { +return static function (): LocalAlternativePaymentMethodsModule { return new LocalAlternativePaymentMethodsModule(); }; diff --git a/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php b/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php index 88edf6b31..ea55d4b0b 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php +++ b/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php @@ -9,32 +9,39 @@ declare(strict_types=1); namespace WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods; -use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry; use WC_Order; -use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider; -use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface; -use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface; +use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry; +use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; +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; /** * Class LocalAlternativePaymentMethodsModule */ -class LocalAlternativePaymentMethodsModule implements ModuleInterface { +class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingModule, ExecutableModule { + use ModuleClassNameIdTrait; /** * {@inheritDoc} */ - public function setup(): ServiceProviderInterface { - return new ServiceProvider( - require __DIR__ . '/../services.php', - require __DIR__ . '/../extensions.php' - ); + public function services() : array { + return require __DIR__ . '/../services.php'; } /** * {@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( 'woocommerce_payment_gateways', /** @@ -150,6 +157,8 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface { } } ); + + return true; } /**