From 19e11d4cf7b418b8630ffbb4199125ebecf76a81 Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Thu, 17 Sep 2020 16:50:04 -0300 Subject: [PATCH 1/2] Fix remaining coding standards issues --- .../src/class-wcgatewaymodule.php | 2 +- .../ppcp-webhooks/src/class-webhookmodule.php | 2 +- woocommerce-paypal-commerce-gateway.php | 103 +++++++++--------- 3 files changed, 55 insertions(+), 52 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php b/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php index 577fb1512..374ce0bd2 100644 --- a/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php +++ b/modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php @@ -94,7 +94,7 @@ static function ( $notices ) use ( $container ): array { } ); add_action( - 'woocommerce-paypal-commerce-gateway.deactivate', + 'woocommerce_paypal_commerce_gateway_deactivate', static function () use ( $container ) { delete_option( Settings::KEY ); delete_option( PayPalRequestIdRepository::KEY ); diff --git a/modules/ppcp-webhooks/src/class-webhookmodule.php b/modules/ppcp-webhooks/src/class-webhookmodule.php index 4156f816c..c95c2f37d 100644 --- a/modules/ppcp-webhooks/src/class-webhookmodule.php +++ b/modules/ppcp-webhooks/src/class-webhookmodule.php @@ -64,7 +64,7 @@ static function () use ( $container ) { ); add_action( - 'woocommerce-paypal-commerce-gateway.deactivate', + 'woocommerce_paypal_commerce_gateway_deactivate', static function () use ( $container ) { $registrar = $container->get( 'webhook.registrar' ); /** diff --git a/woocommerce-paypal-commerce-gateway.php b/woocommerce-paypal-commerce-gateway.php index f07e2e507..468f08030 100644 --- a/woocommerce-paypal-commerce-gateway.php +++ b/woocommerce-paypal-commerce-gateway.php @@ -1,17 +1,18 @@ -setup(); - } - $proxy = new ProxyContainer(); - $provider = new CompositeCachingServiceProvider($providers); - $container = new CachingContainer(new DelegatingContainer($provider)); - $proxy->setInnerContainer($container); - foreach ($modules as $module) { - /* @var $module ModuleInterface */ - $module->run($container); - } - $initialized = true; + /** + * Initialize the plugin and its modules. + */ + function init() { + static $initialized; + if ( ! $initialized ) { + $modules = array( new PluginModule() ); + foreach ( glob( plugin_dir_path( __FILE__ ) . 'modules/*/module.php' ) as $module_file ) { + $modules[] = ( require $module_file )(); + } + $providers = array(); + foreach ( $modules as $module ) { + /* @var $module ModuleInterface module */ + $providers[] = $module->setup(); + } + $proxy = new ProxyContainer(); + $provider = new CompositeCachingServiceProvider( $providers ); + $container = new CachingContainer( new DelegatingContainer( $provider ) ); + $proxy->setInnerContainer( $container ); + foreach ( $modules as $module ) { + /* @var $module ModuleInterface module */ + $module->run( $container ); + } + $initialized = true; - } - } + } + } - add_action( - 'plugins_loaded', - function () { - init(); - } - ); - register_activation_hook( - __FILE__, - function () { - init(); - do_action('woocommerce-paypal-commerce-gateway.activate'); - } - ); - register_deactivation_hook( - __FILE__, - function () { - init(); - do_action('woocommerce-paypal-commerce-gateway.deactivate'); - } - ); + add_action( + 'plugins_loaded', + function () { + init(); + } + ); + register_activation_hook( + __FILE__, + function () { + init(); + do_action( 'woocommerce_paypal_commerce_gateway_activate' ); + } + ); + register_deactivation_hook( + __FILE__, + function () { + init(); + do_action( 'woocommerce_paypal_commerce_gateway_deactivate' ); + } + ); -})(); \ No newline at end of file +} )(); From 23f7219a5d701964aea424d5d1d61d3ae5bf7d0c Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Thu, 17 Sep 2020 18:05:41 -0300 Subject: [PATCH 2/2] Minor fix in Travis script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8618f5438..5f37f8f1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,5 +18,5 @@ script: | if [ "$CHANGED_FILES" != "" ]; then composer global require woocommerce/woocommerce-sniffs --update-with-all-dependencies - .config/composer/vendor/bin/phpcs -p $CHANGED_FILES + $HOME/.config/composer/vendor/bin/phpcs -p $CHANGED_FILES fi