From 7807742f92ae4c843aa7a3ac57dc4e812bf51fbb Mon Sep 17 00:00:00 2001 From: jevgenijvisockij Date: Tue, 9 Apr 2024 08:22:38 +0300 Subject: [PATCH] Make cloudsync option to install --- .../admin/AdminMollieSettingsController.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/controllers/admin/AdminMollieSettingsController.php b/controllers/admin/AdminMollieSettingsController.php index 22b79b81c..614bc18c7 100644 --- a/controllers/admin/AdminMollieSettingsController.php +++ b/controllers/admin/AdminMollieSettingsController.php @@ -27,7 +27,7 @@ public function __construct() $this->bootstrap = true; } - private function initCloudSyncAndPsAccounts(): bool + private function initCloudSyncAndPsAccounts(): void { $mboInstaller = new Prestashop\ModuleLibMboInstaller\DependencyBuilder($this->module); @@ -37,7 +37,7 @@ private function initCloudSyncAndPsAccounts(): bool $this->content .= $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/dependency_builder.tpl'); - return false; + return; } $this->context->smarty->assign('module_dir', $this->module->getPathUri()); @@ -47,12 +47,17 @@ private function initCloudSyncAndPsAccounts(): bool $accountsFacade = $this->module->getService('Mollie.PsAccountsFacade'); $accountsService = $accountsFacade->getPsAccountsService(); } catch (PrestaShop\PsAccountsInstaller\Installer\Exception\InstallerException $e) { - $accountsInstaller = $this->module->getService('Mollie.PsAccountsInstaller'); - $accountsInstaller->install(); - $accountsFacade = $this->module->getService('Mollie.PsAccountsFacade'); - $accountsService = $accountsFacade->getPsAccountsService(); + try { + $accountsInstaller = $this->module->getService('Mollie.PsAccountsInstaller'); + $accountsInstaller->install(); + $accountsFacade = $this->module->getService('Mollie.PsAccountsFacade'); + $accountsService = $accountsFacade->getPsAccountsService(); + } catch (Exception $e) { + $this->context->controller->errors[] = $e->getMessage(); + + return; + } } - try { Media::addJsDef([ 'contextPsAccounts' => $accountsFacade->getPsAccountsPresenter() @@ -81,7 +86,7 @@ private function initCloudSyncAndPsAccounts(): bool $this->content .= $this->context->smarty->fetch($this->module->getLocalPath() . 'views/templates/admin/cloudsync.tpl'); - return true; + return; } public function postProcess() @@ -94,10 +99,9 @@ public function postProcess() $this->module->getService(\Mollie\Builder\Content\LogoInfoBlock::class), $this->module->getLocalPath() . 'views/templates/admin/logo.tpl' ); - $cloudSyncComplete = $this->initCloudSyncAndPsAccounts(); - if (!$cloudSyncComplete) { - return; - } + + $this->initCloudSyncAndPsAccounts(); + /** @var \Mollie\Repository\ModuleRepository $moduleRepository */ $moduleRepository = $this->module->getService(\Mollie\Repository\ModuleRepository::class); $moduleDatabaseVersion = $moduleRepository->getModuleDatabaseVersion($this->module->name);