@@ -36,12 +36,12 @@ class System implements ConfigTypeInterface
3636 /**
3737 * Config cache tag.
3838 */
39- const CACHE_TAG = 'config_scopes ' ;
39+ public const CACHE_TAG = 'config_scopes ' ;
4040
4141 /**
4242 * System config type.
4343 */
44- const CONFIG_TYPE = 'system ' ;
44+ public const CONFIG_TYPE = 'system ' ;
4545
4646 /**
4747 * @var string
@@ -173,8 +173,7 @@ public function __construct(
173173 public function get ($ path = '' )
174174 {
175175 if ($ path === '' ) {
176- $ this ->data = array_replace_recursive ($ this ->loadAllData (), $ this ->data );
177-
176+ $ this ->data = $ this ->loadAllData ();
178177 return $ this ->data ;
179178 }
180179
@@ -193,8 +192,7 @@ private function getWithParts($path)
193192
194193 if (count ($ pathParts ) === 1 && $ pathParts [0 ] !== ScopeInterface::SCOPE_DEFAULT ) {
195194 if (!isset ($ this ->data [$ pathParts [0 ]])) {
196- $ data = $ this ->readData ();
197- $ this ->data = array_replace_recursive ($ data , $ this ->data );
195+ $ this ->readData ();
198196 }
199197
200198 return $ this ->data [$ pathParts [0 ]];
@@ -204,7 +202,8 @@ private function getWithParts($path)
204202
205203 if ($ scopeType === ScopeInterface::SCOPE_DEFAULT ) {
206204 if (!isset ($ this ->data [$ scopeType ])) {
207- $ this ->data = array_replace_recursive ($ this ->loadDefaultScopeData ($ scopeType ), $ this ->data );
205+ $ scopeData = $ this ->loadDefaultScopeData () ?? [];
206+ $ this ->setDataByScopeType ($ scopeType , $ scopeData );
208207 }
209208
210209 return $ this ->getDataByPathParts ($ this ->data [$ scopeType ], $ pathParts );
@@ -213,11 +212,8 @@ private function getWithParts($path)
213212 $ scopeId = array_shift ($ pathParts );
214213
215214 if (!isset ($ this ->data [$ scopeType ][$ scopeId ])) {
216- $ scopeData = $ this ->loadScopeData ($ scopeType , $ scopeId );
217-
218- if (!isset ($ this ->data [$ scopeType ][$ scopeId ])) {
219- $ this ->data = array_replace_recursive ($ scopeData , $ this ->data );
220- }
215+ $ scopeData = $ this ->loadScopeData ($ scopeType , $ scopeId ) ?? [];
216+ $ this ->setDataByScopeId ($ scopeType , $ scopeId , $ scopeData );
221217 }
222218
223219 return isset ($ this ->data [$ scopeType ][$ scopeId ])
@@ -256,16 +252,16 @@ private function loadAllData()
256252 /**
257253 * Load configuration data for default scope.
258254 *
259- * @param string $scopeType
260255 * @return array
261256 */
262- private function loadDefaultScopeData ($ scopeType )
257+ private function loadDefaultScopeData ()
263258 {
264259 if (!$ this ->cacheState ->isEnabled (Config::TYPE_IDENTIFIER )) {
265260 return $ this ->readData ();
266261 }
267262
268- $ loadAction = function () use ($ scopeType ) {
263+ $ loadAction = function () {
264+ $ scopeType = ScopeInterface::SCOPE_DEFAULT ;
269265 $ cachedData = $ this ->cache ->load ($ this ->configType . '_ ' . $ scopeType );
270266 $ scopeData = false ;
271267 if ($ cachedData !== false ) {
@@ -325,6 +321,35 @@ private function loadScopeData($scopeType, $scopeId)
325321 );
326322 }
327323
324+ /**
325+ * Sets data according to scope type.
326+ *
327+ * @param string|null $scopeType
328+ * @param array $scopeData
329+ * @return void
330+ */
331+ private function setDataByScopeType (?string $ scopeType , array $ scopeData ): void
332+ {
333+ if (!isset ($ this ->data [$ scopeType ]) && isset ($ scopeData [$ scopeType ])) {
334+ $ this ->data [$ scopeType ] = $ scopeData [$ scopeType ];
335+ }
336+ }
337+
338+ /**
339+ * Sets data according to scope type and id.
340+ *
341+ * @param string|null $scopeType
342+ * @param string|null $scopeId
343+ * @param array $scopeData
344+ * @return void
345+ */
346+ private function setDataByScopeId (?string $ scopeType , ?string $ scopeId , array $ scopeData ): void
347+ {
348+ if (!isset ($ this ->data [$ scopeType ][$ scopeId ]) && isset ($ scopeData [$ scopeType ][$ scopeId ])) {
349+ $ this ->data [$ scopeType ][$ scopeId ] = $ scopeData [$ scopeType ][$ scopeId ];
350+ }
351+ }
352+
328353 /**
329354 * Cache configuration data.
330355 *
0 commit comments