From 8ca580fcaf22f1bdfbb8ffee653dcf23b9916fd1 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 15 Jan 2025 11:49:54 +0100 Subject: [PATCH 1/3] fix: account integration --- config.xml | 2 +- ps_eventbus.php | 2 +- src/Service/PsAccountsAdapterService.php | 40 ++++++++++++++---------- tests/phpstan/phpstan.neon | 14 ++++++++- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/config.xml b/config.xml index 9d65e736..830d98b2 100644 --- a/config.xml +++ b/config.xml @@ -9,4 +9,4 @@ 0 0 - \ No newline at end of file + diff --git a/ps_eventbus.php b/ps_eventbus.php index 65ab809c..80afbf81 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -95,7 +95,7 @@ public function __construct() $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; - $this->version = '0.0.0'; + $this->version = '4.0.1'; $this->module_key = '7d76e08a13331c6c393755886ec8d5ce'; parent::__construct(); diff --git a/src/Service/PsAccountsAdapterService.php b/src/Service/PsAccountsAdapterService.php index d877993d..327506e6 100644 --- a/src/Service/PsAccountsAdapterService.php +++ b/src/Service/PsAccountsAdapterService.php @@ -54,8 +54,6 @@ public function __construct(ModuleHelper $moduleHelper) * Get psAccounts module main class, or null if module is'nt ready * * @return false|\ModuleCore - * - * @throws \PrestaShopException */ public function getModule() { @@ -70,8 +68,6 @@ public function getModule() * Get psAccounts service, or null if module is'nt ready * * @return mixed - * - * @throws \PrestaShopException */ public function getService() { @@ -79,54 +75,64 @@ public function getService() return false; } - return $this->psAccountModule->getService('PrestaShop\Module\PsAccounts\Service\PsAccountsService'); + try { + return $this->psAccountModule->getService('PrestaShop\Module\PsAccounts\Service\PsAccountsService'); + } catch (\Exception $e) { + return false; + } } /** * Get presenter from psAccounts, or null if module is'nt ready * * @return mixed - * - * @throws \PrestaShopException */ public function getPresenter() { - if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts') || !$this->getService()) { return false; } - return $this->psAccountModule->getService('PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter'); + try { + return $this->psAccountModule->getService('PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter'); + } catch (\Exception $e) { + return false; + } } /** * Get shopUuid from psAccounts, or null if module is'nt ready * * @return string - * - * @throws \PrestaShopException */ public function getShopUuid() { - if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts') || !$this->getService()) { return ''; } - return $this->getService()->getShopUuid(); + try { + return $this->getService()->getShopUuid(); + } catch (\Exception $e) { + return ''; + } } /** * Get refreshToken from psAccounts, or null if module is'nt ready * * @return string - * - * @throws \PrestaShopException */ public function getOrRefreshToken() { - if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) { + if (!$this->moduleHelper->isInstalledAndActive('ps_accounts') || !$this->getService()) { return ''; } - return $this->getService()->getOrRefreshToken(); + try { + return $this->getService()->getOrRefreshToken(); + } catch (\Exception $e) { + return ''; + } } } diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index 3da45ab6..afc92c44 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -3,7 +3,19 @@ includes: - %currentWorkingDirectory%/tests/phpstan/phpstan-9-0.neon parameters: paths: - - ../../src + - ../../src/Api + - ../../src/Config + - ../../src/Exception + - ../../src/Factory + - ../../src/Formatter + - ../../src/Handler + - ../../src/Helper + - ../../src/Log + - ../../src/Module + - ../../src/Repository + - ../../src/Service + - ../../src/ServiceContainer + - ../../src/Traits - ../../controllers - ../../config - ../../ps_eventbus.php From cfd3cfafb134f4fa199761aada194a9c62a6df04 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 15 Jan 2025 11:50:52 +0100 Subject: [PATCH 2/3] fix: revert version --- ps_eventbus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ps_eventbus.php b/ps_eventbus.php index 80afbf81..65ab809c 100644 --- a/ps_eventbus.php +++ b/ps_eventbus.php @@ -95,7 +95,7 @@ public function __construct() $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; - $this->version = '4.0.1'; + $this->version = '0.0.0'; $this->module_key = '7d76e08a13331c6c393755886ec8d5ce'; parent::__construct(); From 9afc7856de08c8f604db7f32e913569434c63776 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 15 Jan 2025 11:52:10 +0100 Subject: [PATCH 3/3] fix: phpstan config --- tests/phpstan/phpstan.neon | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index afc92c44..3da45ab6 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -3,19 +3,7 @@ includes: - %currentWorkingDirectory%/tests/phpstan/phpstan-9-0.neon parameters: paths: - - ../../src/Api - - ../../src/Config - - ../../src/Exception - - ../../src/Factory - - ../../src/Formatter - - ../../src/Handler - - ../../src/Helper - - ../../src/Log - - ../../src/Module - - ../../src/Repository - - ../../src/Service - - ../../src/ServiceContainer - - ../../src/Traits + - ../../src - ../../controllers - ../../config - ../../ps_eventbus.php