33 * Copyright © Magento, Inc. All rights reserved.
44 * See COPYING.txt for license details.
55 */
6+ declare (strict_types=1 );
7+
68namespace Magento \Customer \Model \Config \Backend \Show ;
79
10+ use Magento \Config \App \Config \Source \ModularConfigSource ;
811use Magento \Eav \Model \Entity \Attribute \AbstractAttribute ;
912use Magento \Framework \App \Config \ScopeConfigInterface ;
13+ use Magento \Framework \App \ObjectManager ;
1014
1115/**
1216 * Customer Show Customer Model
1317 *
1418 * @author Magento Core Team <core@magentocommerce.com>
19+ * @SuppressWarnings(PHPMD.UnusedPrivateField)
1520 */
1621class Customer extends \Magento \Framework \App \Config \Value
1722{
@@ -32,6 +37,11 @@ class Customer extends \Magento\Framework\App\Config\Value
3237 */
3338 private $ telephoneShowDefaultValue = 'req ' ;
3439
40+ /**
41+ * @var ModularConfigSource
42+ */
43+ private $ configSource ;
44+
3545 /**
3646 * @var array
3747 */
@@ -52,6 +62,8 @@ class Customer extends \Magento\Framework\App\Config\Value
5262 * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
5363 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
5464 * @param array $data
65+ * @param ModularConfigSource|null $configSource
66+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
5567 */
5668 public function __construct (
5769 \Magento \Framework \Model \Context $ context ,
@@ -62,11 +74,13 @@ public function __construct(
6274 \Magento \Eav \Model \Config $ eavConfig ,
6375 \Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
6476 \Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
65- array $ data = []
77+ array $ data = [],
78+ ModularConfigSource $ configSource = null
6679 ) {
6780 $ this ->_eavConfig = $ eavConfig ;
6881 parent ::__construct ($ context , $ registry , $ config , $ cacheTypeList , $ resource , $ resourceCollection , $ data );
6982 $ this ->storeManager = $ storeManager ;
83+ $ this ->configSource = $ configSource ?: ObjectManager::getInstance ()->get (ModularConfigSource::class);
7084 }
7185
7286 /**
@@ -140,7 +154,8 @@ public function afterDelete()
140154 $ attributeObject ->save ();
141155 }
142156 } 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 );
144159 foreach ($ this ->_getAttributeObjects () as $ attributeObject ) {
145160 $ attributeObject ->setData ('is_required ' , $ valueConfig ['is_required ' ]);
146161 $ attributeObject ->setData ('is_visible ' , $ valueConfig ['is_visible ' ]);
0 commit comments