Skip to content

Commit

Permalink
fix: account integration (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
fox-john authored Jan 15, 2025
1 parent 13084ad commit 934aaa5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
<confirmUninstall><![CDATA[This action will immediately prevent your PrestaShop services and Community services from working as they are using PrestaShop CloudSync for syncing.]]></confirmUninstall>
<is_configurable>0</is_configurable>
<need_instance>0</need_instance>
</module>
</module>
40 changes: 23 additions & 17 deletions src/Service/PsAccountsAdapterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -70,63 +68,71 @@ public function getModule()
* Get psAccounts service, or null if module is'nt ready
*
* @return mixed
*
* @throws \PrestaShopException
*/
public function getService()
{
if (!$this->moduleHelper->isInstalledAndActive('ps_accounts')) {
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 '';
}
}
}

0 comments on commit 934aaa5

Please sign in to comment.