3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Customer \Model \Config \Backend \Show ;
7
9
10
+ use Magento \Config \App \Config \Source \ModularConfigSource ;
8
11
use Magento \Eav \Model \Entity \Attribute \AbstractAttribute ;
9
12
use Magento \Framework \App \Config \ScopeConfigInterface ;
13
+ use Magento \Framework \App \ObjectManager ;
10
14
11
15
/**
12
16
* Customer Show Customer Model
13
17
*
14
18
* @author Magento Core Team <[email protected] >
19
+ * @SuppressWarnings(PHPMD.UnusedPrivateField)
15
20
*/
16
21
class Customer extends \Magento \Framework \App \Config \Value
17
22
{
@@ -32,6 +37,11 @@ class Customer extends \Magento\Framework\App\Config\Value
32
37
*/
33
38
private $ telephoneShowDefaultValue = 'req ' ;
34
39
40
+ /**
41
+ * @var ModularConfigSource
42
+ */
43
+ private $ configSource ;
44
+
35
45
/**
36
46
* @var array
37
47
*/
@@ -52,6 +62,8 @@ class Customer extends \Magento\Framework\App\Config\Value
52
62
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
53
63
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
54
64
* @param array $data
65
+ * @param ModularConfigSource|null $configSource
66
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
55
67
*/
56
68
public function __construct (
57
69
\Magento \Framework \Model \Context $ context ,
@@ -62,11 +74,13 @@ public function __construct(
62
74
\Magento \Eav \Model \Config $ eavConfig ,
63
75
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
64
76
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
65
- array $ data = []
77
+ array $ data = [],
78
+ ModularConfigSource $ configSource = null
66
79
) {
67
80
$ this ->_eavConfig = $ eavConfig ;
68
81
parent ::__construct ($ context , $ registry , $ config , $ cacheTypeList , $ resource , $ resourceCollection , $ data );
69
82
$ this ->storeManager = $ storeManager ;
83
+ $ this ->configSource = $ configSource ?: ObjectManager::getInstance ()->get (ModularConfigSource::class);
70
84
}
71
85
72
86
/**
@@ -140,7 +154,8 @@ public function afterDelete()
140
154
$ attributeObject ->save ();
141
155
}
142
156
} elseif ($ this ->getScope () == ScopeConfigInterface::SCOPE_TYPE_DEFAULT ) {
143
- $ valueConfig = $ this ->getValueConfig ($ this ->telephoneShowDefaultValue );
157
+ $ defaulValue = $ this ->configSource ->get (ScopeConfigInterface::SCOPE_TYPE_DEFAULT . '/ ' . $ this ->getPath ());
158
+ $ valueConfig = $ this ->getValueConfig ($ defaulValue === [] ? '' : $ defaulValue );
144
159
foreach ($ this ->_getAttributeObjects () as $ attributeObject ) {
145
160
$ attributeObject ->setData ('is_required ' , $ valueConfig ['is_required ' ]);
146
161
$ attributeObject ->setData ('is_visible ' , $ valueConfig ['is_visible ' ]);
0 commit comments