Skip to content

Commit

Permalink
Merge pull request #957 from GytisZum/PIPRES-442/upgrade-logs
Browse files Browse the repository at this point in the history
PIPRES-442/ logs added to track installation progress
  • Loading branch information
GytisZum authored Jul 16, 2024
2 parents 9724683 + 29643e0 commit 5629bb8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ private function loadEnv()
*/
public function install()
{
PrestaShopLogger::addLog('Mollie install started', 1, null, 'Mollie', 1);

if (!$this->isPhpVersionCompliant()) {
$this->_errors[] = $this->l('You\'re using an outdated PHP version. Upgrade your PHP version to use this module. The Mollie module supports versions PHP 7.2.0 and higher.');

Expand All @@ -166,16 +168,20 @@ public function install()

return false;
}
PrestaShopLogger::addLog('Mollie prestashop install successful', 1, null, 'Mollie', 1);

// TODO inject base install and subscription services
$coreInstaller = $this->getService(Mollie\Install\Installer::class);
PrestaShopLogger::addLog('Mollie core install initiated', 1, null, 'Mollie', 1);

if (!$coreInstaller->install()) {
$this->_errors = array_merge($this->_errors, $coreInstaller->getErrors());

return false;
}

PrestaShopLogger::addLog('Mollie core install successful', 1, null, 'Mollie', 1);

$subscriptionInstaller = new Installer(
new DatabaseTableInstaller(),
new AttributeInstaller(
Expand All @@ -187,13 +193,15 @@ public function install()
),
new HookInstaller($this)
);
PrestaShopLogger::addLog('Mollie subscription installer initiated', 1, null, 'Mollie', 1);

if (!$subscriptionInstaller->install()) {
$this->_errors = array_merge($this->_errors, $subscriptionInstaller->getErrors());
parent::uninstall();

return false;
}
PrestaShopLogger::addLog('Mollie subscription install successful', 1, null, 'Mollie', 1);

return true;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Mollie\Utility\MultiLangUtility;
use OrderState;
use PrestaShopException;
use PrestaShopLogger;
use Tab;
use Tools;
use Validate;
Expand Down Expand Up @@ -96,8 +97,11 @@ public function install()
$this->module->registerHook($hook);
}

PrestaShopLogger::addLog('Mollie hooks registered successful', 1, null, 'Mollie', 1);

try {
$this->orderStateInstaller->install();
PrestaShopLogger::addLog('Mollie order state install successful', 1, null, 'Mollie', 1);
} catch (CouldNotInstallModule $e) {
$errorHandler->handle($e, $e->getCode(), false);
$this->errors[] = $this->module->l('Unable to install Mollie statuses', self::FILE_NAME);
Expand All @@ -107,6 +111,7 @@ public function install()

try {
$this->initConfig();
PrestaShopLogger::addLog('Mollie configurations installed', 1, null, 'Mollie', 1);
} catch (Exception $e) {
$errorHandler->handle($e, $e->getCode(), false);
$this->errors[] = $this->module->l('Unable to install config', self::FILE_NAME);
Expand All @@ -115,6 +120,7 @@ public function install()
}
try {
$this->setDefaultCarrierStatuses();
PrestaShopLogger::addLog('Mollie default carriers installed', 1, null, 'Mollie', 1);
} catch (Exception $e) {
$errorHandler->handle($e, $e->getCode(), false);
$this->errors[] = $this->module->l('Unable to install default carrier statuses', self::FILE_NAME);
Expand All @@ -126,6 +132,7 @@ public function install()

try {
$this->installVoucherFeatures();
PrestaShopLogger::addLog('Mollie voucher features installed', 1, null, 'Mollie', 1);
} catch (Exception $e) {
$errorHandler->handle($e, $e->getCode(), false);
$this->errors[] = $this->module->l('Unable to install voucher attributes', self::FILE_NAME);
Expand All @@ -134,6 +141,7 @@ public function install()
}

$this->copyEmailTemplates();
PrestaShopLogger::addLog('Mollie email templates copied', 1, null, 'Mollie', 1);

return $this->databaseTableInstaller->install();
}
Expand Down
11 changes: 11 additions & 0 deletions subscription/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace Mollie\Subscription\Install;

use PrestaShopLogger;

if (!defined('_PS_VERSION_')) {
exit;
}
Expand Down Expand Up @@ -43,22 +45,31 @@ public function install(): bool
{
if (!$this->databaseInstaller->install()) {
$this->errors = $this->databaseInstaller->getErrors();
PrestaShopLogger::addLog('Mollie subscription databases install failed', 1, null, 'Mollie', 1);

return false;
}

PrestaShopLogger::addLog('Mollie subscription databases installed', 1, null, 'Mollie', 1);

if (!$this->attributeInstaller->install()) {
$this->errors = $this->attributeInstaller->getErrors();
PrestaShopLogger::addLog('Mollie subscription attributes install failed', 1, null, 'Mollie', 1);

return false;
}

PrestaShopLogger::addLog('Mollie subscription attributes install successful', 1, null, 'Mollie', 1);

if (!$this->hookInstaller->install()) {
$this->errors = $this->hookInstaller->getErrors();
PrestaShopLogger::addLog('Mollie subscription hooks install failed', 1, null, 'Mollie', 1);

return false;
}

PrestaShopLogger::addLog('Mollie subscription hooks install successful', 1, null, 'Mollie', 1);

return true;
}
}

0 comments on commit 5629bb8

Please sign in to comment.