File tree Expand file tree Collapse file tree 4 files changed +21
-1
lines changed
app/code/Magento/Config/Model/Config
dev/tests/integration/testsuite/Magento/Config Expand file tree Collapse file tree 4 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 66
77namespace Magento \Config \Model \Config ;
88
9+ use Magento \Config \Model \Config \Structure \Element \Field ;
910use Magento \Framework \Exception \ValidatorException ;
1011
1112/**
@@ -40,6 +41,11 @@ public function __construct(Structure $structure)
4041 */
4142 public function validate ($ path )
4243 {
44+ $ element = $ this ->structure ->getElementByConfigPath ($ path );
45+ if ($ element instanceof Field && $ element ->getConfigPath ()) {
46+ $ path = $ element ->getConfigPath ();
47+ }
48+
4349 $ allPaths = $ this ->structure ->getFieldPaths ();
4450
4551 if (!array_key_exists ($ path , $ allPaths )) {
Original file line number Diff line number Diff line change @@ -191,7 +191,7 @@ public function getElementByConfigPath($path)
191191 {
192192 $ allPaths = $ this ->getFieldPaths ();
193193
194- if (isset ($ allPaths [$ path ])) {
194+ if (isset ($ allPaths [$ path ]) && is_array ( $ allPaths [ $ path ]) ) {
195195 $ path = array_shift ($ allPaths [$ path ]);
196196 }
197197
Original file line number Diff line number Diff line change 77namespace Magento \Config \Console \Command ;
88
99use Magento \Config \Model \Config \Backend \Admin \Custom ;
10+ use Magento \Config \Model \Config \PathValidator ;
1011use Magento \Config \Model \Config \Structure \Converter ;
1112use Magento \Config \Model \Config \Structure \Data as StructureData ;
1213use Magento \Directory \Model \Currency ;
@@ -444,6 +445,15 @@ public function configSetValidDataProvider()
444445 ];
445446 }
446447
448+ /**
449+ * Test validate path when field has custom config_path
450+ */
451+ public function testValidatePathWithCustomConfigPath (): void
452+ {
453+ $ pathValidator = $ this ->objectManager ->get (PathValidator::class);
454+ $ this ->assertTrue ($ pathValidator ->validate ('general/group/subgroup/second_field ' ));
455+ }
456+
447457 /**
448458 * Set configuration and check this value from DB with success message this command should display
449459 *
Original file line number Diff line number Diff line change 1313 <field id =" field" translate =" label" type =" text" sortOrder =" 100" showInDefault =" 1" showInWebsite =" 1" showInStore =" 0" >
1414 <label >Label</label >
1515 </field >
16+ <field id =" second_field" translate =" label" type =" text" sortOrder =" 10" showInDefault =" 1" showInWebsite =" 1" showInStore =" 0" >
17+ <label >Label Second</label >
18+ <config_path >custom/config_path/second_field</config_path >
19+ </field >
1620 </group >
1721 </group >
1822 </section >
You can’t perform that action at this time.
0 commit comments