From faa9ac4efba5cab5de9361b013afb3a833439092 Mon Sep 17 00:00:00 2001 From: mandan2 Date: Mon, 9 Oct 2023 15:47:52 +0300 Subject: [PATCH] phpstan and minor ps_evenbus install tweaks --- .../admin/AdminMollieSettingsController.php | 6 +++++- mollie.php | 14 ++++++++------ src/Config/Config.php | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/controllers/admin/AdminMollieSettingsController.php b/controllers/admin/AdminMollieSettingsController.php index 220454b89..73905ace5 100644 --- a/controllers/admin/AdminMollieSettingsController.php +++ b/controllers/admin/AdminMollieSettingsController.php @@ -227,15 +227,19 @@ private function setEnvironmentForCloudSync(): void return; } + /* @phpstan-ignore-next-line */ /** @var \Ps_eventbus $eventbusModule */ $eventbusModule = \Module::getInstanceByName('ps_eventbus'); + /* @phpstan-ignore-next-line */ if (version_compare($eventbusModule->version, '1.9.0', '>=')) { + /* @phpstan-ignore-next-line */ /** @var PresenterService $eventbusPresenterService */ $eventbusPresenterService = $eventbusModule->getService(PresenterService::class); + /* @phpstan-ignore-next-line */ Media::addJsDef([ - 'contextPsEventbus' => $eventbusPresenterService->expose($this->module, ['orders',]), + 'contextPsEventbus' => $eventbusPresenterService->expose($this->module, ['orders']), ]); } diff --git a/mollie.php b/mollie.php index 789976403..f8d4adcfa 100755 --- a/mollie.php +++ b/mollie.php @@ -185,15 +185,17 @@ public function install() $moduleManager = ModuleManagerBuilder::getInstance()->build(); try { - if (!$moduleManager->isInstalled('ps_eventbus')) { - $moduleManager->install('ps_eventbus'); - } - - if (!$moduleManager->isEnabled('ps_eventbus')) { + /** + * NOTE: install method upgrades the module if there is a newer version + */ + if ( + $moduleManager->isInstalled('ps_eventbus') && + !$moduleManager->isEnabled('ps_eventbus') + ) { $moduleManager->enable('ps_eventbus'); } - $moduleManager->upgrade('ps_eventbus'); + $moduleManager->install('ps_eventbus'); } catch (Exception $exception) { $this->_errors[] = $this->l('Failed to install/upgrade Prestashop event bus module. Please contact support.'); diff --git a/src/Config/Config.php b/src/Config/Config.php index 07a0c2a57..f7030c46f 100644 --- a/src/Config/Config.php +++ b/src/Config/Config.php @@ -313,7 +313,7 @@ class Config const MOLLIE_BUTTON_ORDER_TOTAL_REFRESH = 'MOLLIE_BUTTON_ORDER_TOTAL_REFRESH'; public const PRESTASHOP_ACCOUNTS_INSTALLER_VERSION = '5.0.0'; - public const PRESTASHOP_CLOUDSYNC_CDN = 'https://integration-assets.prestashop3.com/ext/cloudsync-merchant-sync-consent/latest/cloudsync-cdc.js'; + public const PRESTASHOP_CLOUDSYNC_CDN = 'https://assets.prestashop3.com/ext/cloudsync-merchant-sync-consent/latest/cloudsync-cdc.js'; // TODO migrate functions below to separate service public static function getStatuses()