@@ -50,18 +50,21 @@ class WebsiteRepository implements \Magento\Store\Api\WebsiteRepositoryInterface
5050 /**
5151 * @var Config
5252 */
53- private $ appConfig ;
53+ private Config $ appConfig ;
5454
5555 /**
5656 * @param WebsiteFactory $factory
5757 * @param CollectionFactory $websiteCollectionFactory
58+ * @param Config|null $appConfig
5859 */
5960 public function __construct (
6061 WebsiteFactory $ factory ,
61- CollectionFactory $ websiteCollectionFactory
62+ CollectionFactory $ websiteCollectionFactory ,
63+ ?Config $ appConfig = null
6264 ) {
6365 $ this ->factory = $ factory ;
6466 $ this ->websiteCollectionFactory = $ websiteCollectionFactory ;
67+ $ this ->appConfig = $ appConfig ?? ObjectManager::getInstance ()->get (Config::class);
6568 }
6669
6770 /**
@@ -73,7 +76,7 @@ public function get($code)
7376 return $ this ->entities [$ code ];
7477 }
7578
76- $ websiteData = $ this ->getAppConfig () ->get ('scopes ' , "websites/ $ code " , []);
79+ $ websiteData = $ this ->appConfig ->get ('scopes ' , "websites/ $ code " , []);
7780 $ website = $ this ->factory ->create ([
7881 'data ' => $ websiteData
7982 ]);
@@ -97,7 +100,7 @@ public function getById($id)
97100 return $ this ->entitiesById [$ id ];
98101 }
99102
100- $ websiteData = $ this ->getAppConfig () ->get ('scopes ' , "websites/ $ id " , []);
103+ $ websiteData = $ this ->appConfig ->get ('scopes ' , "websites/ $ id " , []);
101104 $ website = $ this ->factory ->create ([
102105 'data ' => $ websiteData
103106 ]);
@@ -118,7 +121,7 @@ public function getById($id)
118121 public function getList ()
119122 {
120123 if (!$ this ->allLoaded ) {
121- $ websites = $ this ->getAppConfig () ->get ('scopes ' , 'websites ' , []);
124+ $ websites = $ this ->appConfig ->get ('scopes ' , 'websites ' , []);
122125 foreach ($ websites as $ data ) {
123126 $ website = $ this ->factory ->create ([
124127 'data ' => $ data
@@ -169,13 +172,11 @@ public function clean()
169172 * Retrieve application config.
170173 *
171174 * @deprecated 100.1.3 Should be lazy loaded with a proxy via the DI.
175+ * @see self::$appConfig
172176 * @return Config
173177 */
174- private function getAppConfig ()
178+ private function getAppConfig (): Config
175179 {
176- if (!$ this ->appConfig ) {
177- $ this ->appConfig = ObjectManager::getInstance ()->get (Config::class);
178- }
179180 return $ this ->appConfig ;
180181 }
181182
@@ -186,7 +187,7 @@ private function getAppConfig()
186187 */
187188 private function initDefaultWebsite ()
188189 {
189- $ websites = (array ) $ this ->getAppConfig () ->get ('scopes ' , 'websites ' , []);
190+ $ websites = (array )$ this ->appConfig ->get ('scopes ' , 'websites ' , []);
190191 foreach ($ websites as $ data ) {
191192 if (isset ($ data ['is_default ' ]) && $ data ['is_default ' ] == 1 ) {
192193 if ($ this ->default ) {
0 commit comments