@@ -50,18 +50,21 @@ class WebsiteRepository implements \Magento\Store\Api\WebsiteRepositoryInterface
50
50
/**
51
51
* @var Config
52
52
*/
53
- private $ appConfig ;
53
+ private Config $ appConfig ;
54
54
55
55
/**
56
56
* @param WebsiteFactory $factory
57
57
* @param CollectionFactory $websiteCollectionFactory
58
+ * @param Config|null $appConfig
58
59
*/
59
60
public function __construct (
60
61
WebsiteFactory $ factory ,
61
- CollectionFactory $ websiteCollectionFactory
62
+ CollectionFactory $ websiteCollectionFactory ,
63
+ ?Config $ appConfig = null
62
64
) {
63
65
$ this ->factory = $ factory ;
64
66
$ this ->websiteCollectionFactory = $ websiteCollectionFactory ;
67
+ $ this ->appConfig = $ appConfig ?? ObjectManager::getInstance ()->get (Config::class);
65
68
}
66
69
67
70
/**
@@ -73,7 +76,7 @@ public function get($code)
73
76
return $ this ->entities [$ code ];
74
77
}
75
78
76
- $ websiteData = $ this ->getAppConfig () ->get ('scopes ' , "websites/ $ code " , []);
79
+ $ websiteData = $ this ->appConfig ->get ('scopes ' , "websites/ $ code " , []);
77
80
$ website = $ this ->factory ->create ([
78
81
'data ' => $ websiteData
79
82
]);
@@ -97,7 +100,7 @@ public function getById($id)
97
100
return $ this ->entitiesById [$ id ];
98
101
}
99
102
100
- $ websiteData = $ this ->getAppConfig () ->get ('scopes ' , "websites/ $ id " , []);
103
+ $ websiteData = $ this ->appConfig ->get ('scopes ' , "websites/ $ id " , []);
101
104
$ website = $ this ->factory ->create ([
102
105
'data ' => $ websiteData
103
106
]);
@@ -118,7 +121,7 @@ public function getById($id)
118
121
public function getList ()
119
122
{
120
123
if (!$ this ->allLoaded ) {
121
- $ websites = $ this ->getAppConfig () ->get ('scopes ' , 'websites ' , []);
124
+ $ websites = $ this ->appConfig ->get ('scopes ' , 'websites ' , []);
122
125
foreach ($ websites as $ data ) {
123
126
$ website = $ this ->factory ->create ([
124
127
'data ' => $ data
@@ -169,13 +172,11 @@ public function clean()
169
172
* Retrieve application config.
170
173
*
171
174
* @deprecated 100.1.3 Should be lazy loaded with a proxy via the DI.
175
+ * @see self::$appConfig
172
176
* @return Config
173
177
*/
174
- private function getAppConfig ()
178
+ private function getAppConfig (): Config
175
179
{
176
- if (!$ this ->appConfig ) {
177
- $ this ->appConfig = ObjectManager::getInstance ()->get (Config::class);
178
- }
179
180
return $ this ->appConfig ;
180
181
}
181
182
@@ -186,7 +187,7 @@ private function getAppConfig()
186
187
*/
187
188
private function initDefaultWebsite ()
188
189
{
189
- $ websites = (array ) $ this ->getAppConfig () ->get ('scopes ' , 'websites ' , []);
190
+ $ websites = (array )$ this ->appConfig ->get ('scopes ' , 'websites ' , []);
190
191
foreach ($ websites as $ data ) {
191
192
if (isset ($ data ['is_default ' ]) && $ data ['is_default ' ] == 1 ) {
192
193
if ($ this ->default ) {
0 commit comments