File tree Expand file tree Collapse file tree 4 files changed +62
-40
lines changed Expand file tree Collapse file tree 4 files changed +62
-40
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \Config \ViewModel ;
9
+
10
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
11
+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
12
+ use Magento \Store \Model \ScopeInterface ;
13
+
14
+ class CountryFilter implements ArgumentInterface
15
+ {
16
+ /**
17
+ * Config path to UE country list
18
+ */
19
+ private const XML_PATH_EU_COUNTRIES_LIST = 'general/country/eu_countries ' ;
20
+
21
+ /**
22
+ * @var ScopeConfigInterface
23
+ */
24
+ private $ scopeConfig ;
25
+
26
+ /**
27
+ * @param ScopeConfigInterface $scopeConfig
28
+ */
29
+ public function __construct (
30
+ ScopeConfigInterface $ scopeConfig
31
+ ) {
32
+ $ this ->scopeConfig = $ scopeConfig ;
33
+ }
34
+
35
+ /**
36
+ * Fetch EU countries list
37
+ *
38
+ * @param Int|null $storeId
39
+ * @return false|string[]
40
+ */
41
+ public function getEuCountryList ($ storeId = null )
42
+ {
43
+ $ euCountries = explode (
44
+ ', ' ,
45
+ $ this ->scopeConfig ->getValue (
46
+ self ::XML_PATH_EU_COUNTRIES_LIST ,
47
+ ScopeInterface::SCOPE_STORE ,
48
+ $ storeId
49
+ )
50
+ );
51
+
52
+ return $ euCountries ;
53
+ }
54
+ }
Original file line number Diff line number Diff line change 8
8
<page xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" layout =" admin-2columns-left" xsi : noNamespaceSchemaLocation =" urn:magento:framework:View/Layout/etc/page_configuration.xsd" >
9
9
<body >
10
10
<referenceContainer name =" js" >
11
- <block class =" Magento\Backend\Block\Template" name =" js.system_config_js" template =" Magento_Config::system/config/js.phtml" />
11
+ <block class =" Magento\Backend\Block\Template" name =" js.system_config_js" template =" Magento_Config::system/config/js.phtml" >
12
+ <arguments >
13
+ <argument name =" countryFilter" xsi : type =" object" >Magento\Config\ViewModel\CountryFilter</argument >
14
+ </arguments >
15
+ </block >
12
16
<block class =" Magento\Backend\Block\Template" name =" js.system_shipping_applicable_country" template =" Magento_Backend::system/shipping/applicable_country.phtml" />
13
17
</referenceContainer >
14
18
<referenceContainer name =" page.main.actions" >
Original file line number Diff line number Diff line change 6
6
7
7
/**
8
8
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
9
+ * @var \Magento\Config\ViewModel\CountryFilter $countryFilter
9
10
*/
10
11
?>
11
12
@@ -86,7 +87,8 @@ originModel.prototype = {
86
87
script ;
87
88
88
89
$ scriptString .= 'this.regionsUrl = " ' . $ block ->escapeJs ($ block ->getUrl ('directory/json/countryRegion ' )) . '"; ' ;
89
- $ euCountries = $ this ->helper (\Magento \Config \Helper \Country::class)->getEuCountryList ();
90
+ $ countryFilter = $ block ->getData ('countryFilter ' );
91
+ $ euCountries = $ countryFilter ->getEuCountryList ();
90
92
$ scriptString .= 'this.euCountryList = ' . json_encode ($ euCountries );
91
93
92
94
$ scriptString .= <<<script
You can’t perform that action at this time.
0 commit comments