17
17
class Config implements ComponentInterface
18
18
{
19
19
const PATH_THEME_ID = 'design/theme/theme_id ' ;
20
+ const ENCRYPTED_MODEL = \Magento \Config \Model \Config \Backend \Encrypted::class;
20
21
21
22
protected $ alias = 'config ' ;
22
23
protected $ name = 'Configuration ' ;
@@ -57,16 +58,26 @@ class Config implements ComponentInterface
57
58
*/
58
59
private $ log ;
59
60
61
+ /**
62
+ * @var ScopeConfig\Initial
63
+ */
64
+ private $ initialConfig ;
65
+
60
66
/**
61
67
* Config constructor.
62
68
* @param ConfigResource $configResource
63
69
* @param ScopeConfig $scopeConfig
70
+ * @param ScopeConfig\Initial $initialConfig
64
71
* @param CollectionFactory $collectionFactory
65
72
* @param EncryptorInterface $encryptor
73
+ * @param WebsiteFactory $websiteFactory
74
+ * @param StoreFactory $storeFactory
75
+ * @param LoggerInterface $log
66
76
*/
67
77
public function __construct (
68
78
ConfigResource $ configResource ,
69
79
ScopeConfig $ scopeConfig ,
80
+ ScopeConfig \Initial $ initialConfig ,
70
81
CollectionFactory $ collectionFactory ,
71
82
EncryptorInterface $ encryptor ,
72
83
WebsiteFactory $ websiteFactory ,
@@ -75,6 +86,7 @@ public function __construct(
75
86
) {
76
87
$ this ->configResource = $ configResource ;
77
88
$ this ->scopeConfig = $ scopeConfig ;
89
+ $ this ->initialConfig = $ initialConfig ;
78
90
$ this ->collectionFactory = $ collectionFactory ;
79
91
$ this ->encryptor = $ encryptor ;
80
92
$ this ->websiteFactory = $ websiteFactory ;
@@ -98,12 +110,15 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
98
110
if ($ scope == "global " ) {
99
111
foreach ($ configurations as $ configuration ) {
100
112
// Handle encryption parameter
113
+
101
114
$ encryption = 0 ;
102
115
if (isset ($ configuration ['encryption ' ]) && $ configuration ['encryption ' ] == 1 ) {
103
116
$ encryption = 1 ;
104
117
}
105
118
106
119
$ convertedConfiguration = $ this ->convert ($ configuration );
120
+ // Check if the path uses an encryption model. If yes, set encryption to true
121
+ $ encryption = $ this ->determineEncryption ($ convertedConfiguration , $ encryption );
107
122
$ this ->setGlobalConfig (
108
123
$ convertedConfiguration ['path ' ],
109
124
$ convertedConfiguration ['value ' ],
@@ -121,6 +136,8 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
121
136
$ encryption = 1 ;
122
137
}
123
138
$ convertedConfiguration = $ this ->convert ($ configuration );
139
+ // Check if the path uses an encryption model. If yes, set encryption to true
140
+ $ encryption = $ this ->determineEncryption ($ convertedConfiguration , $ encryption );
124
141
$ this ->setWebsiteConfig (
125
142
$ convertedConfiguration ['path ' ],
126
143
$ convertedConfiguration ['value ' ],
@@ -141,6 +158,8 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
141
158
}
142
159
143
160
$ convertedConfiguration = $ this ->convert ($ configuration );
161
+ // Check if the path uses an encryption model. If yes, set encryption to true
162
+ $ encryption = $ this ->determineEncryption ($ convertedConfiguration , $ encryption );
144
163
$ this ->setStoreConfig (
145
164
$ convertedConfiguration ['path ' ],
146
165
$ convertedConfiguration ['value ' ],
@@ -156,6 +175,21 @@ public function execute($data = null) //phpcs:ignore Generic.Metrics.NestingLeve
156
175
}
157
176
}
158
177
178
+ private function determineEncryption (array $ configuration , $ encryption )
179
+ {
180
+ $ metaData = $ this ->initialConfig ->getMetadata ();
181
+
182
+ foreach ($ metaData as $ path => $ processor ) {
183
+ if ($ path == $ configuration ['path ' ]) {
184
+ if (isset ($ processor ['backendModel ' ]) && $ processor ['backendModel ' ] === self ::ENCRYPTED_MODEL ) {
185
+ $ encryption = 1 ;
186
+ }
187
+ }
188
+ }
189
+
190
+ return $ encryption ;
191
+ }
192
+
159
193
private function setGlobalConfig ($ path , $ value , $ encrypted = 0 )
160
194
{
161
195
try {
0 commit comments