File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
app/code/Magento/Config/Model/Config
dev/tests/integration/testsuite/Magento/Config Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 6
6
7
7
namespace Magento \Config \Model \Config ;
8
8
9
+ use Magento \Config \Model \Config \Structure \Element \Field ;
9
10
use Magento \Framework \Exception \ValidatorException ;
10
11
11
12
/**
@@ -41,10 +42,10 @@ public function __construct(Structure $structure)
41
42
public function validate ($ path )
42
43
{
43
44
$ element = $ this ->structure ->getElementByConfigPath ($ path );
44
- if ($ element ->getConfigPath ()) {
45
+ if ($ element instanceof Field && $ element ->getConfigPath ()) {
45
46
$ path = $ element ->getConfigPath ();
46
47
}
47
-
48
+
48
49
$ allPaths = $ this ->structure ->getFieldPaths ();
49
50
50
51
if (!array_key_exists ($ path , $ allPaths )) {
Original file line number Diff line number Diff line change 7
7
namespace Magento \Config \Console \Command ;
8
8
9
9
use Magento \Config \Model \Config \Backend \Admin \Custom ;
10
+ use Magento \Config \Model \Config \PathValidator ;
10
11
use Magento \Config \Model \Config \Structure \Converter ;
11
12
use Magento \Config \Model \Config \Structure \Data as StructureData ;
12
13
use Magento \Directory \Model \Currency ;
@@ -444,6 +445,15 @@ public function configSetValidDataProvider()
444
445
];
445
446
}
446
447
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
+
447
457
/**
448
458
* Set configuration and check this value from DB with success message this command should display
449
459
*
Original file line number Diff line number Diff line change 13
13
<field id =" field" translate =" label" type =" text" sortOrder =" 100" showInDefault =" 1" showInWebsite =" 1" showInStore =" 0" >
14
14
<label >Label</label >
15
15
</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 >
16
20
</group >
17
21
</group >
18
22
</section >
You can’t perform that action at this time.
0 commit comments