@@ -101,6 +101,8 @@ public function __construct(
101
101
}
102
102
103
103
/**
104
+ * Get config value by path.
105
+ *
104
106
* System configuration is separated by scopes (default, websites, stores). Configuration of a scope is inherited
105
107
* from its parent scope (store inherits website).
106
108
*
@@ -121,7 +123,7 @@ public function __construct(
121
123
public function get ($ path = '' )
122
124
{
123
125
if ($ path === '' ) {
124
- $ this ->data = array_replace_recursive ($ this ->loadAllData () , $ this ->data );
126
+ $ this ->data = array_replace_recursive ($ this ->data , $ this ->loadAllData () );
125
127
126
128
return $ this ->data ;
127
129
}
@@ -142,7 +144,7 @@ private function getWithParts($path)
142
144
if (count ($ pathParts ) === 1 && $ pathParts [0 ] !== ScopeInterface::SCOPE_DEFAULT ) {
143
145
if (!isset ($ this ->data [$ pathParts [0 ]])) {
144
146
$ data = $ this ->readData ();
145
- $ this ->data = array_replace_recursive ($ data , $ this ->data );
147
+ $ this ->data = array_replace_recursive ($ this -> data , $ this ->postProcessor -> process ( $ data) );
146
148
}
147
149
148
150
return $ this ->data [$ pathParts [0 ]];
@@ -152,7 +154,12 @@ private function getWithParts($path)
152
154
153
155
if ($ scopeType === ScopeInterface::SCOPE_DEFAULT ) {
154
156
if (!isset ($ this ->data [$ scopeType ])) {
155
- $ this ->data = array_replace_recursive ($ this ->loadDefaultScopeData ($ scopeType ), $ this ->data );
157
+ $ this ->data = array_replace_recursive (
158
+ $ this ->data ,
159
+ $ scopeData = $ this ->loadDefaultScopeData ($ scopeType )
160
+ );
161
+ $ scopeData = $ this ->postProcessor ->process ($ scopeData );
162
+ $ this ->data = array_replace_recursive ($ this ->data , $ scopeData );
156
163
}
157
164
158
165
return $ this ->getDataByPathParts ($ this ->data [$ scopeType ], $ pathParts );
@@ -162,10 +169,9 @@ private function getWithParts($path)
162
169
163
170
if (!isset ($ this ->data [$ scopeType ][$ scopeId ])) {
164
171
$ scopeData = $ this ->loadScopeData ($ scopeType , $ scopeId );
165
-
166
- if (!isset ($ this ->data [$ scopeType ][$ scopeId ])) {
167
- $ this ->data = array_replace_recursive ($ scopeData , $ this ->data );
168
- }
172
+ $ this ->data = array_replace_recursive ($ this ->data , $ scopeData );
173
+ $ scopeData = $ this ->postProcessor ->process ($ scopeData );
174
+ $ this ->data = array_replace_recursive ($ this ->data , $ scopeData );
169
175
}
170
176
171
177
return isset ($ this ->data [$ scopeType ][$ scopeId ])
@@ -186,9 +192,10 @@ private function loadAllData()
186
192
$ data = $ this ->readData ();
187
193
} else {
188
194
$ data = $ this ->serializer ->unserialize ($ cachedData );
195
+ $ this ->data = $ data ;
189
196
}
190
197
191
- return $ data ;
198
+ return $ this -> postProcessor -> process ( $ data) ;
192
199
}
193
200
194
201
/**
@@ -243,6 +250,7 @@ private function loadScopeData($scopeType, $scopeId)
243
250
244
251
/**
245
252
* Cache configuration data.
253
+ *
246
254
* Caches data per scope to avoid reading data for all scopes on every request
247
255
*
248
256
* @param array $data
@@ -308,9 +316,6 @@ private function getDataByPathParts($data, $pathParts)
308
316
private function readData (): array
309
317
{
310
318
$ this ->data = $ this ->reader ->read ();
311
- $ this ->data = $ this ->postProcessor ->process (
312
- $ this ->data
313
- );
314
319
315
320
return $ this ->data ;
316
321
}
0 commit comments