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