Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions app/code/Magento/Config/Block/System/Config/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ public function __construct(
\Magento\Config\Model\Config\Structure $configStructure,
\Magento\Config\Block\System\Config\Form\Fieldset\Factory $fieldsetFactory,
\Magento\Config\Block\System\Config\Form\Field\Factory $fieldFactory,
array $data = []
array $data = [],
SettingChecker $settingChecker = null
) {
parent::__construct($context, $registry, $formFactory, $data);
$this->_configFactory = $configFactory;
$this->_configStructure = $configStructure;
$this->_fieldsetFactory = $fieldsetFactory;
$this->_fieldFactory = $fieldFactory;
$this->settingChecker = $settingChecker ?: ObjectManager::getInstance()->get(SettingChecker::class);

$this->_scopeLabels = [
self::SCOPE_DEFAULT => __('[GLOBAL]'),
Expand All @@ -158,18 +160,6 @@ public function __construct(
];
}

/**
* @deprecated 100.1.2
* @return SettingChecker
*/
private function getSettingChecker()
{
if ($this->settingChecker === null) {
$this->settingChecker = ObjectManager::getInstance()->get(SettingChecker::class);
}
return $this->settingChecker;
}

/**
* Initialize objects required to render config form
*
Expand Down Expand Up @@ -366,9 +356,8 @@ protected function _initElement(

$sharedClass = $this->_getSharedCssClass($field);
$requiresClass = $this->_getRequiresCssClass($field, $fieldPrefix);
$isReadOnly = $this->isReadOnly($field, $path);

$isReadOnly = $this->getElementVisibility()->isDisabled($field->getPath())
?: $this->getSettingChecker()->isReadOnly($path, $this->getScope(), $this->getStringScopeCode());
$formField = $fieldset->addField(
$elementId,
$field->getType(),
Expand Down Expand Up @@ -417,7 +406,7 @@ private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Fie
{
$data = $this->getAppConfigDataValue($path);

$placeholderValue = $this->getSettingChecker()->getPlaceholderValue(
$placeholderValue = $this->settingChecker->getPlaceholderValue(
$path,
$this->getScope(),
$this->getStringScopeCode()
Expand Down Expand Up @@ -718,6 +707,7 @@ protected function _getAdditionalElementTypes()
*
* @TODO delete this methods when {^see above^} is done
* @return string
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
*/
public function getSectionCode()
{
Expand All @@ -729,6 +719,7 @@ public function getSectionCode()
*
* @TODO delete this methods when {^see above^} is done
* @return string
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
*/
public function getWebsiteCode()
{
Expand All @@ -740,6 +731,7 @@ public function getWebsiteCode()
*
* @TODO delete this methods when {^see above^} is done
* @return string
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
*/
public function getStoreCode()
{
Expand Down Expand Up @@ -797,6 +789,26 @@ private function getAppConfig()
return $this->appConfig;
}

/**
* Check Path is Readonly
*
* @param \Magento\Config\Model\Config\Structure\Element\Field $field
* @param string $path
* @return boolean
*/
private function isReadOnly(\Magento\Config\Model\Config\Structure\Element\Field $field, $path)
{
$isReadOnly = $this->settingChecker->isReadOnly(
$path,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
if (!$isReadOnly) {
$isReadOnly = $this->getElementVisibility()->isDisabled($field->getPath())
?: $this->settingChecker->isReadOnly($path, $this->getScope(), $this->getStringScopeCode());
}
return $isReadOnly;
}

/**
* Retrieve deployment config data value by path
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ protected function setUp()
$this->_fieldsetFactoryMock = $this->createMock(\Magento\Config\Block\System\Config\Form\Fieldset\Factory::class);
$this->_fieldFactoryMock = $this->createMock(\Magento\Config\Block\System\Config\Form\Field\Factory::class);
$this->_coreConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$settingCheckerMock = $this->getMockBuilder(SettingChecker::class)
->disableOriginalConstructor()
->getMock();

$this->_backendConfigMock = $this->createMock(\Magento\Config\Model\Config::class);

Expand Down Expand Up @@ -150,6 +153,7 @@ protected function setUp()
'fieldsetFactory' => $this->_fieldsetFactoryMock,
'fieldFactory' => $this->_fieldFactoryMock,
'context' => $context,
'settingChecker' => $settingCheckerMock,
];

$objectArguments = $helper->getConstructArguments(\Magento\Config\Block\System\Config\Form::class, $data);
Expand Down Expand Up @@ -529,7 +533,7 @@ public function testInitFields(

$elementVisibilityMock = $this->getMockBuilder(ElementVisibilityInterface::class)
->getMockForAbstractClass();
$elementVisibilityMock->expects($this->once())
$elementVisibilityMock->expects($this->any())
->method('isDisabled')
->willReturn($isDisabled);

Expand Down