Skip to content

Commit 814eaa5

Browse files
ENGCOM-6390: [Config] Giving the possibility to have a config dependency based on empty config value #25774
2 parents e72b3f7 + 51d61b0 commit 814eaa5

File tree

2 files changed

+16
-1
lines changed
  • app/code/Magento/Config
    • Model/Config/Structure/Element/Dependency
    • Test/Unit/Model/Config/Structure/Element/Dependency

2 files changed

+16
-1
lines changed

app/code/Magento/Config/Model/Config/Structure/Element/Dependency/Field.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\Config\Model\Config\Structure\Element\Dependency;
77

88
/**
9+
* Field
10+
*
911
* @api
1012
* @since 100.0.2
1113
*/
@@ -41,7 +43,7 @@ public function __construct(array $fieldData = [], $fieldPrefix = "")
4143
if (isset($fieldData['separator'])) {
4244
$this->_values = explode($fieldData['separator'], $fieldData['value']);
4345
} else {
44-
$this->_values = [$fieldData['value']];
46+
$this->_values = [isset($fieldData['value']) ? $fieldData['value'] : ''];
4547
}
4648
$fieldId = $fieldPrefix . (isset(
4749
$fieldData['dependPath']

app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/Dependency/FieldTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class FieldTest extends \PHPUnit\Framework\TestCase
1212
*/
1313
const SIMPLE_VALUE = 'someValue';
1414

15+
const EMPTY_VALUE = '';
16+
1517
const COMPLEX_VALUE1 = 'value_1';
1618

1719
const COMPLEX_VALUE2 = 'value_2';
@@ -150,8 +152,19 @@ public function getValuesDataProvider()
150152
return [
151153
[$this->_getSimpleData(), true, [self::SIMPLE_VALUE]],
152154
[$this->_getSimpleData(), false, [self::SIMPLE_VALUE]],
155+
[$this->_getSimpleEmptyData(), false, [static::EMPTY_VALUE]],
153156
[$this->_getComplexData(), true, $complexDataValues],
154157
[$this->_getComplexData(), false, $complexDataValues]
155158
];
156159
}
160+
161+
/**
162+
* Providing a field data with no field value
163+
*
164+
* @return array
165+
*/
166+
protected function _getSimpleEmptyData(): array
167+
{
168+
return ['dependPath' => ['section_2', 'group_3', 'field_4']];
169+
}
157170
}

0 commit comments

Comments
 (0)