@@ -143,13 +143,15 @@ public function __construct(
143
143
\Magento \Config \Model \Config \Structure $ configStructure ,
144
144
\Magento \Config \Block \System \Config \Form \Fieldset \Factory $ fieldsetFactory ,
145
145
\Magento \Config \Block \System \Config \Form \Field \Factory $ fieldFactory ,
146
- array $ data = []
146
+ array $ data = [],
147
+ SettingChecker $ settingChecker = null
147
148
) {
148
149
parent ::__construct ($ context , $ registry , $ formFactory , $ data );
149
150
$ this ->_configFactory = $ configFactory ;
150
151
$ this ->_configStructure = $ configStructure ;
151
152
$ this ->_fieldsetFactory = $ fieldsetFactory ;
152
153
$ this ->_fieldFactory = $ fieldFactory ;
154
+ $ this ->settingChecker = $ settingChecker ?: ObjectManager::getInstance ()->get (SettingChecker::class);
153
155
154
156
$ this ->_scopeLabels = [
155
157
self ::SCOPE_DEFAULT => __ ('[GLOBAL] ' ),
@@ -158,18 +160,6 @@ public function __construct(
158
160
];
159
161
}
160
162
161
- /**
162
- * @deprecated 100.1.2
163
- * @return SettingChecker
164
- */
165
- private function getSettingChecker ()
166
- {
167
- if ($ this ->settingChecker === null ) {
168
- $ this ->settingChecker = ObjectManager::getInstance ()->get (SettingChecker::class);
169
- }
170
- return $ this ->settingChecker ;
171
- }
172
-
173
163
/**
174
164
* Initialize objects required to render config form
175
165
*
@@ -366,9 +356,8 @@ protected function _initElement(
366
356
367
357
$ sharedClass = $ this ->_getSharedCssClass ($ field );
368
358
$ requiresClass = $ this ->_getRequiresCssClass ($ field , $ fieldPrefix );
359
+ $ isReadOnly = $ this ->isReadOnly ($ field , $ path );
369
360
370
- $ isReadOnly = $ this ->getElementVisibility ()->isDisabled ($ field ->getPath ())
371
- ?: $ this ->getSettingChecker ()->isReadOnly ($ path , $ this ->getScope (), $ this ->getStringScopeCode ());
372
361
$ formField = $ fieldset ->addField (
373
362
$ elementId ,
374
363
$ field ->getType (),
@@ -417,7 +406,7 @@ private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Fie
417
406
{
418
407
$ data = $ this ->getAppConfigDataValue ($ path );
419
408
420
- $ placeholderValue = $ this ->getSettingChecker () ->getPlaceholderValue (
409
+ $ placeholderValue = $ this ->settingChecker ->getPlaceholderValue (
421
410
$ path ,
422
411
$ this ->getScope (),
423
412
$ this ->getStringScopeCode ()
@@ -718,6 +707,7 @@ protected function _getAdditionalElementTypes()
718
707
*
719
708
* @TODO delete this methods when {^see above^} is done
720
709
* @return string
710
+ * @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
721
711
*/
722
712
public function getSectionCode ()
723
713
{
@@ -729,6 +719,7 @@ public function getSectionCode()
729
719
*
730
720
* @TODO delete this methods when {^see above^} is done
731
721
* @return string
722
+ * @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
732
723
*/
733
724
public function getWebsiteCode ()
734
725
{
@@ -740,6 +731,7 @@ public function getWebsiteCode()
740
731
*
741
732
* @TODO delete this methods when {^see above^} is done
742
733
* @return string
734
+ * @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
743
735
*/
744
736
public function getStoreCode ()
745
737
{
@@ -797,6 +789,26 @@ private function getAppConfig()
797
789
return $ this ->appConfig ;
798
790
}
799
791
792
+ /**
793
+ * Check Path is Readonly
794
+ *
795
+ * @param \Magento\Config\Model\Config\Structure\Element\Field $field
796
+ * @param string $path
797
+ * @return boolean
798
+ */
799
+ private function isReadOnly (\Magento \Config \Model \Config \Structure \Element \Field $ field , $ path )
800
+ {
801
+ $ isReadOnly = $ this ->settingChecker ->isReadOnly (
802
+ $ path ,
803
+ ScopeConfigInterface::SCOPE_TYPE_DEFAULT
804
+ );
805
+ if (!$ isReadOnly ) {
806
+ $ isReadOnly = $ this ->getElementVisibility ()->isDisabled ($ field ->getPath ())
807
+ ?: $ this ->settingChecker ->isReadOnly ($ path , $ this ->getScope (), $ this ->getStringScopeCode ());
808
+ }
809
+ return $ isReadOnly ;
810
+ }
811
+
800
812
/**
801
813
* Retrieve deployment config data value by path
802
814
*
0 commit comments