36
36
use Magento \Variable \Model \Variable ;
37
37
use Magento \Variable \Model \VariableFactory ;
38
38
use Psr \Log \LoggerInterface ;
39
+ use Magento \Store \Model \Information as StoreInformation ;
39
40
40
41
/**
41
42
* Core Email Template Filter Model
@@ -201,6 +202,11 @@ class Filter extends Template
201
202
*/
202
203
private $ pubDirectoryRead ;
203
204
205
+ /**
206
+ * @var StoreInformation
207
+ */
208
+ private $ storeInformation ;
209
+
204
210
205
211
/**
206
212
* Filter constructor.
@@ -222,6 +228,7 @@ class Filter extends Template
222
228
* @param CssInliner $cssInliner
223
229
* @param array $variables
224
230
* @param array $directiveProcessors
231
+ * @param StoreInformation|null $storeInformation
225
232
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
226
233
*/
227
234
public function __construct (
@@ -242,7 +249,8 @@ public function __construct(
242
249
Filesystem $ pubDirectory ,
243
250
CssInliner $ cssInliner ,
244
251
$ variables = [],
245
- array $ directiveProcessors = []
252
+ array $ directiveProcessors = [],
253
+ StoreInformation $ storeInformation = null
246
254
) {
247
255
$ this ->_escaper = $ escaper ;
248
256
$ this ->_assetRepo = $ assetRepo ;
@@ -259,6 +267,8 @@ public function __construct(
259
267
$ this ->cssProcessor = $ cssProcessor ;
260
268
$ this ->pubDirectory = $ pubDirectory ;
261
269
$ this ->configVariables = $ configVariables ;
270
+ $ this ->storeInformation = $ storeInformation ?:
271
+ \Magento \Framework \App \ObjectManager::getInstance ()->get (StoreInformation::class);
262
272
parent ::__construct ($ string , $ variables , $ directiveProcessors , $ variableResolver );
263
273
}
264
274
@@ -825,18 +835,29 @@ private function validateProtocolDirectiveHttpScheme(array $params) : void
825
835
*
826
836
* @param string[] $construction
827
837
* @return string
838
+ * @throws NoSuchEntityException
828
839
*/
829
840
public function configDirective ($ construction )
830
841
{
831
842
$ configValue = '' ;
832
843
$ params = $ this ->getParameters ($ construction [2 ]);
833
844
$ storeId = $ this ->getStoreId ();
845
+ $ store = $ this ->_storeManager ->getStore ($ storeId );
846
+ $ storeInformationObj = $ this ->storeInformation
847
+ ->getStoreInformationObject ($ store );
834
848
if (isset ($ params ['path ' ]) && $ this ->isAvailableConfigVariable ($ params ['path ' ])) {
835
849
$ configValue = $ this ->_scopeConfig ->getValue (
836
850
$ params ['path ' ],
837
851
ScopeInterface::SCOPE_STORE ,
838
852
$ storeId
839
853
);
854
+ if ($ params ['path ' ] == "general/store_information/country_id " ) {
855
+ $ configValue = $ storeInformationObj ->getData ('country ' );
856
+ } elseif ($ params ['path ' ] == "general/store_information/region_id " ) {
857
+ $ configValue = $ storeInformationObj ->getData ('region ' )?
858
+ $ storeInformationObj ->getData ('region ' ):
859
+ $ configValue ;
860
+ }
840
861
}
841
862
return $ configValue ;
842
863
}
0 commit comments