11<?php
2+
23/**
34 * Copyright since 2007 PrestaShop SA and Contributors
45 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
@@ -76,7 +77,7 @@ public function getModule()
7677 *
7778 * @return mixed
7879 */
79- public function getService ()
80+ public function getAccountService ()
8081 {
8182 if (!$ this ->moduleHelper ->isInstalledAndActive ('ps_accounts ' )) {
8283 return false ;
@@ -94,42 +95,19 @@ public function getService()
9495 }
9596 }
9697
97- /**
98- * Get presenter from psAccounts, or null if module is'nt ready
99- *
100- * @return mixed
101- */
102- public function getPresenter ()
103- {
104- if (!$ this ->moduleHelper ->isInstalledAndActive ('ps_accounts ' ) || !$ this ->getService ()) {
105- return false ;
106- }
107-
108- try {
109- return $ this ->psAccountModule ->getService ('PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter ' );
110- } catch (\Exception $ e ) {
111- $ this ->errorHandler ->handle (
112- new \PrestaShopException ('Failed to load PsAccountsPresenter ' , 0 , $ e ),
113- true
114- );
115-
116- return false ;
117- }
118- }
119-
12098 /**
12199 * Get shopUuid from psAccounts, or null if module is'nt ready
122100 *
123101 * @return string
124102 */
125103 public function getShopUuid ()
126104 {
127- if (!$ this ->moduleHelper ->isInstalledAndActive ('ps_accounts ' ) || !$ this ->getService ()) {
105+ if (!$ this ->moduleHelper ->isInstalledAndActive ('ps_accounts ' ) || !$ this ->getAccountService ()) {
128106 return '' ;
129107 }
130108
131109 try {
132- return $ this ->getService ()->getShopUuid ();
110+ return $ this ->getAccountService ()->getShopUuid ();
133111 } catch (\Exception $ e ) {
134112 $ this ->errorHandler ->handle (
135113 new \PrestaShopException ('Failed to get shop uuid from ps_account ' , 0 , $ e ),
@@ -145,14 +123,22 @@ public function getShopUuid()
145123 *
146124 * @return string
147125 */
148- public function getOrRefreshToken ()
126+ public function getShopToken ()
149127 {
150- if (!$ this ->moduleHelper ->isInstalledAndActive ('ps_accounts ' ) || !$ this ->getService ()) {
128+ if (!$ this ->moduleHelper ->isInstalledAndActive ('ps_accounts ' ) || !$ this ->getAccountService ()) {
129+ return '' ;
130+ }
131+
132+ if ($ this ->psAccountModule == false ) {
151133 return '' ;
152134 }
153135
154136 try {
155- return $ this ->getService ()->getOrRefreshToken ();
137+ if (version_compare ($ this ->psAccountModule ->version , '7.1.1 ' , '>= ' )) {
138+ return $ this ->getAccountService ()->getShopToken ();
139+ } else {
140+ return $ this ->getAccountService ()->getOrRefreshToken ();
141+ }
156142 } catch (\Exception $ e ) {
157143 $ this ->errorHandler ->handle (
158144 new \PrestaShopException ('Failed to get refresh token from ps_account ' , 0 , $ e ),
0 commit comments