4
4
*/
5
5
namespace Tobai \GeoStoreSwitcher \Model \Config ;
6
6
7
- use Magento \Store \Api \Data \StoreInterface ;
8
-
9
7
class General
10
8
{
11
9
/**
12
10
* @var \Tobai\GeoStoreSwitcher\Model\Config\ScopeConfig
13
11
*/
14
- protected $ scopeConfig ;
15
-
16
- /**
17
- * @var \Tobai\GeoStoreSwitcher\Helper\Config\AppState
18
- */
19
- protected $ appStateHelper ;
12
+ private $ scopeConfig ;
20
13
21
14
/**
22
15
* @var \Tobai\GeoStoreSwitcher\Helper\Config\Request
23
16
*/
24
- protected $ requestHelper ;
17
+ private $ requestHelper ;
25
18
26
19
/**
27
20
* @param \Tobai\GeoStoreSwitcher\Model\Config\ScopeConfig $scopeConfig
28
- * @param \Tobai\GeoStoreSwitcher\Helper\Config\AppState $appStateHelper
29
21
* @param \Tobai\GeoStoreSwitcher\Helper\Config\Request $requestHelper
30
22
*/
31
23
public function __construct (
32
24
\Tobai \GeoStoreSwitcher \Model \Config \ScopeConfig $ scopeConfig ,
33
- \Tobai \GeoStoreSwitcher \Helper \Config \AppState $ appStateHelper ,
34
25
\Tobai \GeoStoreSwitcher \Helper \Config \Request $ requestHelper
35
26
) {
36
27
$ this ->scopeConfig = $ scopeConfig ;
37
- $ this ->appStateHelper = $ appStateHelper ;
38
28
$ this ->requestHelper = $ requestHelper ;
39
29
}
40
30
41
31
/**
42
- * @param \Magento\Store\Api\Data\StoreInterface $store
43
- * @return $this
32
+ * @param \Tobai\GeoStoreSwitcher\Model\Config\ScopeConfig $scopeConfig
33
+ * @return void
44
34
*/
45
- public function setOriginStore ( StoreInterface $ store )
35
+ public function setScopeConfig ( \ Tobai \ GeoStoreSwitcher \ Model \ Config \ ScopeConfig $ scopeConfig )
46
36
{
47
- $ this ->scopeConfig ->setOriginStore ($ store );
48
- return $ this ;
37
+ $ this ->scopeConfig = $ scopeConfig ;
49
38
}
50
39
51
40
/**
52
41
* @return bool
53
42
*/
54
43
public function isAvailable ()
55
44
{
56
- return $ this ->appStateHelper ->isFrontendArea ()
57
- && !$ this ->requestHelper ->isCurrentIp ($ this ->getWhiteIps ())
45
+ return !$ this ->requestHelper ->isCurrentIp ($ this ->getWhiteIps ())
58
46
&& !$ this ->requestHelper ->isCurrentUserAgent ($ this ->getWhiteUa ())
59
47
&& $ this ->isActive ();
60
48
}
@@ -64,7 +52,7 @@ public function isAvailable()
64
52
*/
65
53
public function isActive ()
66
54
{
67
- return $ this ->scopeConfig ->getFrontendStoreOrBackendValue ('tobai_geo_store_switcher/general/active ' );
55
+ return $ this ->scopeConfig ->getStoreValue ('tobai_geo_store_switcher/general/active ' );
68
56
}
69
57
70
58
/**
@@ -116,15 +104,15 @@ public function isMappingSore()
116
104
public function isCountries ()
117
105
{
118
106
return $ this ->isActive ()
119
- && $ this ->scopeConfig ->getFrontendWebsiteOrBackendValue ('tobai_geo_store_switcher/general/by_countries ' );
107
+ && $ this ->scopeConfig ->getWebsiteValue ('tobai_geo_store_switcher/general/by_countries ' );
120
108
}
121
109
122
110
/**
123
111
* @return array
124
112
*/
125
113
public function getCountryList ()
126
114
{
127
- $ countriesData = $ this ->scopeConfig ->getFrontendWebsiteOrBackendValue ('tobai_geo_store_switcher/general/country_list ' );
115
+ $ countriesData = $ this ->scopeConfig ->getWebsiteValue ('tobai_geo_store_switcher/general/country_list ' );
128
116
$ countries = $ this ->isCountries () && !empty ($ countriesData ) ? explode (', ' , $ countriesData ) : [];
129
117
return $ countries ;
130
118
}
@@ -144,7 +132,7 @@ public function getCountryStore($countryCode)
144
132
public function getGroupCount ()
145
133
{
146
134
return $ this ->isActive ()
147
- ? (int )$ this ->scopeConfig ->getFrontendWebsiteOrBackendValue ('tobai_geo_store_switcher/general/by_groups ' )
135
+ ? (int )$ this ->scopeConfig ->getWebsiteValue ('tobai_geo_store_switcher/general/by_groups ' )
148
136
: 0 ;
149
137
}
150
138
@@ -154,7 +142,7 @@ public function getGroupCount()
154
142
*/
155
143
public function getGroupCountryList ($ group )
156
144
{
157
- $ countriesData = $ this ->scopeConfig ->getFrontendWebsiteOrBackendValue ("tobai_geo_store_switcher/group_ {$ group }/country_list " );
145
+ $ countriesData = $ this ->scopeConfig ->getWebsiteValue ("tobai_geo_store_switcher/group_ {$ group }/country_list " );
158
146
$ countries = !empty ($ countriesData ) ? explode (', ' , $ countriesData ) : [];
159
147
return $ countries ;
160
148
}
0 commit comments